Link to home
Start Free TrialLog in
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]Flag for Luxembourg

asked on

Regex pattern from "xml" like stuff

say we have this string:
<sql>abc</sql><parameter><name>smsc</name><value>62000</value></parameter><parameter><name>msisdn</name><value>123456789</value></parameter><parameter><name>message</name><value>test proc</value></parameter><parameter><name>sourcename</name><value>test</value></parameter>

Open in new window

I want with the Regex.Matches to return the MatchCollection to return all the <parameter>...</parameter> parts.

my first tries was:
<parameter>(.*)</parameter>

Open in new window

which returns this:
<parameter><name>smsc</name><value>62000</value></parameter><parameter><name>msisdn</name><value>123456789</value></parameter><parameter><name>message</name><value>test proc</value></parameter><parameter><name>sourcename</name><value>test</value></parameter>

Open in new window

matching the first <parameter> with the last </parameter> :(

I think this should be quite obvious ...
note: I won't care about people telling me to parse this with xml document or the like ...
I know the arguments, and have my reasons to work like this ...

thanks
Avatar of Pierre François
Pierre François
Flag of Belgium image

Avatar of Guy Hengel [angelIII / a3]

ASKER

with due respect, but I thought I had made clear that:
note: I won't care about people telling me to parse this with xml document or the like ...
I know the arguments, and have my reasons to work like this ...
Your choice...
ASKER CERTIFIED SOLUTION
Avatar of wdosanjos
wdosanjos
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
small but efficient change.
thanks!