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

Gianluigi gradobag at gradobag.it
Tue Aug 22 14:23:28 CEST 2023


Il 22/08/23 14:10, Gianluigi ha scritto:
> Il 22/08/23 13:36, Gianluigi ha scritto:
>> Il 22/08/23 13:20, Benoît Minisini ha scritto:
>>> Le 22/08/2023 à 00:29, T Lee Davidson a écrit :
>>>> On 8/21/23 12:03, Jesus Guardon wrote:
>>>>> The external parenthesis makes the group that captures all 
>>>>> matches. Don't forget to apply the "/gmi" modifiers, which stands 
>>>>> for "global", 
>>>>> "multiline" and case "insensitive", if needed. See it working in my example:
>>>>>
>>>>> https://regex101.com/r/41vaTw/1
>>>>
>>>> Thank you for that pattern, Jesus. It is considerably shorter than 
>>>> the one I was using. But, it still doesn't work in Gambas as there 
>>>> is no Global Match compile option - at least not that I have found.
>>>>
>>>>
>>>
>>> Hi,
>>>
>>> The last commit 
>>> https://gitlab.com/gambas/gambas/-/commit/61bab1771efd4778ae0bccacdbfdede03c7fdb14 
>>> added a RegExp.FindAll() method.
>>>
>>> You are welcome to try it and tell me if it behaves as you expected.
>>>
>>> Thanks.
>>>
>> Hi Benoit,
>>
>> compiling i get this error :
>>
>> Making all in gb.pcre
>> Making all in src
>>   CC       gb_pcre_la-main.lo
>>   CC       gb_pcre_la-regexp2.lo
>> regexp2.c:323:10: fatal error: regexp_common.h: File o directory non 
>> esistente
>>   323 | #include "regexp_common.h"
>>       |          ^~~~~~~~~~~~~~~~~
>> compilation terminated.
>> make[4]: *** [Makefile:514: gb_pcre_la-regexp2.lo] Errore 1
>> make[3]: *** [Makefile:447: all-recursive] Errore 1
>> make[2]: *** [Makefile:379: all] Errore 2
>> make[1]: *** [Makefile:446: all-recursive] Errore 1
>> make: *** [Makefile:387: all] Errore 2
>>
>> Regards
>>
>> Gianluigi
>>
>>
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
> Hi Benoit
>
> the test here worked, but it's slower (5x) than the private function.
> Am I doing something wrong?
> ...

Hi Benoit,

As my usual I said nonsense, it's faster :-)

aFind = hRegExp.FindAll(sText, sExp)

Regards

Gianluigi



More information about the User mailing list