How to find the nth occurence of a string

Thorsten Haude yoo at vranx.de
Wed Oct 18 11:39:38 CEST 2006


Hi,

* Eric Bouyoux wrote (2006-10-18 11:31):
>   Tony Balinski a écrit :
>>You can almost do it with a regex: given N as a decimal, searching for
>>  (?:(?n.*?)(?:SearchString)){N}
>
>   Is anybody able to explain me this regexp. I thought I was able to
>   understand regular expression but it seems I'm not.

(?:(?n.*?)(?:SearchString))

Basically, find anything (including newlines) followed by SearchString
N times. The first inner parens match anything, but are non-greedy
(the ? after the *), the secind inner parens match SearchString, the
outer parens combine the two inner for counting.


Thorsten                                     Faith Kleppinger: Gone Singin'
-- 
War is God's Way to teach geography to Americans.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.nedit.org/pipermail/discuss/attachments/20061018/edc85a5c/attachment.bin


More information about the Discuss mailing list