user3575963
user3575963

Reputation:

android regex error

That is my text i want to do regex

    url: 'http://stackoverflow.com/questions/33048725/ocamllex-regex-syntax-error'

},

That is normal form of regex

url:\s'(.*)'\s*},

Yhat is inside eclipse version with escape

url:\\s'(.*)'\\s*},

but android studio gives error.

Caused by: java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index :

It shows last letter. ,

this , is faulty.

i define patter like this

 pattern = "url:\s'(.*)'\s*},"

Why?

I also used with backslash but still same. This time it shows \ in front of coma.

Upvotes: 0

Views: 91

Answers (1)

vks
vks

Reputation: 67968

url:\\s'(.*)'\\s*\\},

You need to escape {} as well.

Upvotes: 1

Related Questions