[Gambas-user] Multiline RegExp

Ian Haywood ihaywood at ...1979...
Wed Jul 27 12:13:37 CEST 2011


On Wed, Jul 27, 2011 at 5:34 PM, Demosthenes Koptsis
<demosthenesk at ...626...> wrote:

> 2) The Pattern i use is:
> (?i)\b[a-z0-9._%\-]+@[a-z0-9._%\-]+\.[A-Z]{2,4}\b
>
> 3) The result is only one email:
> dimos at ...146...
>
> and not the rest of them.
as you are only calling regexp once, you will only get one result, you
need to set up a While..Wend loop
to go through and find one, then use
Right$(-(Len(sRegExp.Text)+sRegexp.Offset)) to grab the reminder
of the string as search that, until the search fails.

This is inefficient (as a new string is created for each search).
Benoit, is it possible for Regexp.Exec to have an offset parameter,
this would allow more
efficient searching loops.
It would then be possible to write an iterator to grab all occurances
of a regexp, and make it 'easy' like in Ruby/Perl.

Ian




More information about the User mailing list