Solved

Regex pattern from "xml" like stuff

Posted on 2012-04-12
5
529 Views
Last Modified: 2012-08-14
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
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 10

Expert Comment

by:pfrancois
ID: 37837572
0
 
LVL 143

Author Comment

by:Guy Hengel [angelIII / a3]
ID: 37837730
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 ...
0
 
LVL 10

Expert Comment

by:pfrancois
ID: 37838221
Your choice...
0
 
LVL 23

Accepted Solution

by:
wdosanjos earned 500 total points
ID: 37838820
Please try the following:
<parameter>(.*?)</parameter>

Open in new window

0
 
LVL 143

Author Closing Comment

by:Guy Hengel [angelIII / a3]
ID: 37841304
small but efficient change.
thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question