0

I have a string that look like this :

blablablablafunction tr(b){b=b.split("");b=b.reverse();b=b.slice(2);return b.join("")}blablablabla

And i want to get : b=b.split("");b=b.reverse();b=b.slice(2);return b.join("")

with Regex :

var match = "function tr(b){(.*)}";
var f = html.match(match);

And i get null in f.Any idea what is the problem?

1 Answer 1

1

You will have to escape special characters in the regex in this case I believe these are { , } and also ( and )(around the function argument list). Use the escape character(\) to do that. So try this regex:

var match = "function tr\\(b\\)\\{(.*)\\}";
Sign up to request clarification or add additional context in comments.

1 Comment

do you have any example?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.