Regular Expressions Pattern Question

  • Thread starter Thread starter David Brower
  • Start date Start date
D

David Brower

Hi Folks,

I have little knowledge of regular expressions but I am trying to
extract the string "TEST4444" - or whatever name the order might have
- from the following string "Order TEST4444 is not valid."

I am definitely going to have to take the time to learn all about
patterns but for the time being could someone please help me work out
how to do this in VB.NET.

Thank you!

David
 
Dim str As String = "TEST4444"

Dim order As String = str.Substring(4)

MessageBox.Show(order)
 
You could try this:

(?<=Order )\w+(?= is not valid)

It will pick up the word that is between "Order " and " is not valid". The
word may contain letters, numbers, or the "_" character. If your order name
can contain other characters and/or white space, you may want to try:

(?<=Order ).+?(?= is not valid)


Brian Davis
www.knowdotnet.com
 
Sorry, I thought you may have wanted just a solution to extract the order
number. If this is inappropriate then please ignore it.

Regards
 
Back
Top