What is the correct regular expression for this NSString in iOS?

110 Views Asked by At

I have a string that I am confused about how to make a regular expression with:

<a href="/pins/abc-1234-xyz/"

The parts that are ALWAYS the same are:

<a href="/pins/

and

/"

The junk in between can be a-z A-Z 0-9 and the dash (minus) character -

Is this correct?

regularExpressionWithPattern:@"<a href=\"/pins/([^""]*)/"")";
1

There are 1 best solutions below

0
On

This is close, but you need to escape all your doublequotes, and remove the unmatched parenthesis:

regularExpressionWithPattern:@"<a href=\"/pins/([^\"]*)/\"";