Regular expression quantifier questions

Posted by Josemalive on Stack Overflow See other posts from Stack Overflow or by Josemalive
Published on 2010-05-05T11:09:38Z Indexed on 2010/05/05 11:28 UTC
Read the original article Hit count: 268

Filed under:
|

Hello,

Im trying to find a regular expression that matches this kind of URL:

http://sub.domain.com/selector/F/13/K/100546/sampletext/654654/K/sampletext_sampletext.html

and dont match this:

http://sub.domain.com/selector/F/13/K/10546/sampletext/5987/K/sample/K/101/sample_text.html

only if the number of /K/ is minimum 1 and maximum 2 (something with a quantifier like {1,2})

Until this moment i have the following regexp:

http://sub\.domain\.com/selector/F/[0-9]{1,2}/[a-z0-9_-]+/

Now i would need a hand to add any kind of condition like:

Match this if in the text appears the /K/ from 1 to 2 times at most.

Thanks in advance.

Best Regards.

Josema

© Stack Overflow or respective owner

Related posts about regex

Related posts about boost-regex