Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Regex Expression to get data between to tags

Posted on 2007-12-06
8
Medium Priority
?
275 Views
Last Modified: 2012-05-05
I need a regex expresion to get the data between the following two tags:

<Product><11114-7></Product>

It has to loop as there may be up to 200 of them but as little as one.
I am using vbscript if that helps.
0
Comment
Question by:EGormly
[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
  • 5
  • 3
8 Comments
 
LVL 27

Expert Comment

by:ddrudik
ID: 20420280
Provide your multiple instance case as an example.
0
 
LVL 27

Accepted Solution

by:
ddrudik earned 2000 total points
ID: 20420327
If your data looks like:
<Product><11114-7></Product><Product><11114-8></Product><Product><11114-9></Product><Product><11114-10></Product>

With the <>:
<%
Set regEx = New RegExp
regEx.Global = True
regEx.IgnoreCase = True
regEx.MultiLine = True
teststring = "<Product><11114-7></Product><Product><11114-8></Product><Product><11114-9></Product><Product><11114-10></Product>"
regEx.Pattern = "<Product>([\S\s]*?)</Product>"
Set Matches = regEx.Execute(teststring)
%>

Without <>:
<%
Set regEx = New RegExp
regEx.Global = True
regEx.IgnoreCase = True
regEx.MultiLine = True
teststring = "<Product><11114-7></Product><Product><11114-8></Product><Product><11114-9></Product><Product><11114-10></Product>"
regEx.Pattern = "<Product><([\S\s]*?)></Product>"
Set Matches = regEx.Execute(teststring)
%>

If your example text differs from this format, provide your example text.
0
 

Author Comment

by:EGormly
ID: 20420436
wow that is phenomenal..
I must be a bit dense because try as I might, I just could not get that.
I spent a lot of time on regex tutorials and missed the <([\S\s]*?)> part, I couldn't seem to get it right.

One more quick question before I give you the points on this. (which I will regardless of if you answer)
How do I know how many results there are?

'Matches' is an array, that much I know, but how can I tell how many are in the array?


0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 27

Expert Comment

by:ddrudik
ID: 20420464
Matches.Count
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 20420475
Since Matches array would start at index 0, to loop through them:
For z = 0 to Matches.Count-1
0
 

Author Closing Comment

by:EGormly
ID: 31413171
Fastest response time ever, most complete answer I have ever received.
Thank you very much.
0
 

Author Comment

by:EGormly
ID: 20420498
Thanks for going the extra mile and answering that for me.
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 20420513
Thanks for the question and the points, I am glad I could help.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
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…
Suggested Courses

663 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