[Gambas-user] RegExp: How to find all matches of a pattern (global match)?

T Lee Davidson t.lee.davidson at gmail.com
Sun Aug 20 22:29:09 CEST 2023


Given numerous text files containing one or more ip addresses, I am trying to extract all matches in a given file not knowing 
how many there may be.

This is the regular expression I am using:
hRegExp.Compile("(?:IP address: (\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}))")

I have tried compiling with and without RegExp.DotAll, repeating the non-captured group with "+", adding ".*" at beginning and 
end, and various other quantifiers and pattern tweaks I can't even remember now.

But, no matter what, only the first match is returned.


-- 
Lee


More information about the User mailing list