RexEx search for multiple matches

In this XML, i try to find all lines with … tags:

[code]<?xml version="1.0" encoding="UTF-8"?>

1234 123456 ADSL 16000 2464 VDSL 51392 10048 89752921 ADSL SA 16000 89742312 VDSL SA 50 Mbit/s 89753005 ADSL_shared 16000 89742472 ADSL SA 2000 RAM 89760773 ADSL SA 16000 J 89742311 VDSL SA 25 Mbit/s 89742473 ADSL SA 6000 RAM 89739864 ADSL shared 2000 RAM 89739865 ADSL shared 6000 RAM 89743558 VDSL SA 16 Mbit/s 10201 DSL sofort verfuegbar, es konnten nicht alle moeglichen Produkte recherchiert werden

[/code]

For this is use the RexEx Code:

[code]dim rx as new RegEx
rx.SearchPattern = “(?i-Ums)(.+)”

dim match as RegExMatch = rx.Search( sourceText )
[/code]

The XML String Encoding is UTF8.
RegExRX correctly finds 10 times the Groups between the Tags, but in Xojo, only the first one is found (SubexpressionCount = 2).
I already tried to work with ReplaceLineEndings and RexEx Greedy Mode, but nothing works as expected.

do
   if match<>nil then
    ...
    match = rs.Search
  end if
loop until match=nil

Thank you @Jean-Yves Pochez ! :slight_smile:

Your Code and the fact that a simple rx.Search without a TargetString seems to just continue the last Search, fixed the issue. Now it’s working as expected.

BTW: This is just a Quick&Dirty solution while i have to build my XMLParser Classes for the Service. :wink:

I asked Kem to add this snippet to the “copy Xojo native code” menu from RegexRx
because you should always use it like this or you get only the first match.
but so far, no update :wink:

[quote=409083:@Jean-Yves Pochez]I asked Kem to add this snippet to the “copy Xojo native code” menu from RegexRx
because you should always use it like this or you get only the first match.
but so far, no update ;)[/quote]

I am sure @Kem Tekinay will include this in his 64bit Update. :slight_smile:

Probably not. :slight_smile: But I do have an idea that will include this for a future update. Now I just need time to work on it…

you sleep right? skip sleepign one night and it will be done as you are Super-Kem! :slight_smile:

Good advice, because, like most programmers, I write the best code when sleep-deprived. So good, in fact, I later don’t understand why I did it, what I was thinking, or why it doesn’t work.

:stuck_out_tongue:

@Sascha S , I’m curious why you’re not using the native XML classes.

I don’t like the native xml classes because the error detection is not bulletproof.
often, you get an error for a missing caracter.
with regex, you have a better control of the sourcetext.
although I confirm that with an xml text you should use xml classes over regex.

I will do. But for me this stuff looks complicated enough to wrap my own classes around it :stuck_out_tongue:

I do not like this Parent.Child.Child.Chid.Sibbling stuff :slight_smile:

[quote=409096:@Kem Tekinay]Good advice, because, like most programmers, I write the best code when sleep-deprived. So good, in fact, I later don’t understand why I did it, what I was thinking, or why it doesn’t work.

:P[/quote]

Sometimes I don’t understand why my code works :wink: