ios - regEx expression for detecting javascript call function -


for example, there @"javascript:viewdata(3713, 'a', 89360)" string.

i want extract 3713, , 89360 string.

for java, "viewdata\(([^\(]*),[\s\s]\'([^\(]*)\',[\s\s]([^\(]*)\)" can extract strings successfully.

however, couldn't extract them in ios objective-c.

my code below:

nsstring *searchedstring = @"javascript:viewdata(3713, 'a', 89360)"; nsrange   searchedrange = nsmakerange(0, [searchedstring length]); nsstring *pattern = @"<here pattern needed>"; nserror  *error = nil; nsregularexpression* regex = [nsregularexpression regularexpressionwithpattern:pattern options:0 error:&error]; nstextcheckingresult *match = [regex firstmatchinstring:searchedstring options:0 range:searchedrange]; 

then matched string as:

[searchedstring substringwithrange:[match rangeatindex:1]] .. , on.

how can set pattern?

basically regex pattern supposed work in objective-c, too.

however have escape backslashes:

nsstring *pattern = @"viewdata\\(([^\\(]*),[\\s\\s]\\'([^\\(]*)\\',[\\s\\s]([^\\(]*)\\)"; 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -