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?

YosiFZ
  • 7,792
  • 21
  • 114
  • 221

1 Answers1

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\\)\\{(.*)\\}";
Ivaylo Strandjev
  • 69,226
  • 18
  • 123
  • 176