Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular Expression Matching

Status
Not open for further replies.

fcoomermd

Programmer
Nov 20, 2002
218
CA
I am new to Regular Expressions (don't really need to use them much), however need to use in this case.. Kind of a daunting task. I have tried my luck, but am stumbling...
Here is what I need to do.. Search a string, of lots of xml, and pull out the name from the following XML.
<last_Name xmlns=" </last_Name>

What kind of reg expression would match "<last_name...." w/
"</last_Name>" ? and return only the middle?

Having troubles, any help would be appreciated.
Thanks
 
Are you trying to return the contents of just that one only? or are you trying to return all of them?

Or do you have tags with last_name, first_name, age... And you whant to return those?


I am testing some code for you now,
 
This code will find you the contents of the first 'last_name' tag:
Code:
   Dim reg1 As New System.Text.RegularExpressions.Regex("<last_name.*?>(?<lastname>.*?)</last_name>")
   Dim amatch1 As System.Text.RegularExpressions.Match = reg1.Match(MyXmlString)
   If amatch1.Success = True Then
      Last_Name = amatch1.Groups("lastname").Value
   End If

Hope this helps,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top