sin010101
05-13-2010, 08:31 PM
I am trying to pull out an ID number from a string, but cannot figure it out. I have this regex:
Dim string
string = "newline <html><body>newline NAME: John Doe<br />SUBSCRIBER ID: 0010101 <span>more text</span>"
Set SubsriberRegEx = New RegExp
With SubsriberRegEx
.Pattern = "SUBSCRIBER\s+ID:\s+(\d+)"
.IgnoreCase = True
.Global = True
End With
What i want to do is just print out $1, the closest thing i have found is:
Response.Write(SubsriberRegEx.Replace(string, "Subscriber ID: $1"))
Which Prints out:
Subscriber ID: 0010101 more text
Notice the "more text". The problem is that the variable "string" is actually a huge file with a lot of weird characters inside of it.
I know i could change this example regex to:
.Pattern = "SUBSCRIBER\s+ID:\s+(\d+).*"
and that would work in this example, but the file I am using has a lot of characters that ".*" do not match, such as special characters, tabs, newlines.
Is there a way to only access $1 without using the Replace method?
maybe something like:
Set SubscriberID = SubsriberRegEx.Execute(string).$1
Any help would be much appreciated.
Dim string
string = "newline <html><body>newline NAME: John Doe<br />SUBSCRIBER ID: 0010101 <span>more text</span>"
Set SubsriberRegEx = New RegExp
With SubsriberRegEx
.Pattern = "SUBSCRIBER\s+ID:\s+(\d+)"
.IgnoreCase = True
.Global = True
End With
What i want to do is just print out $1, the closest thing i have found is:
Response.Write(SubsriberRegEx.Replace(string, "Subscriber ID: $1"))
Which Prints out:
Subscriber ID: 0010101 more text
Notice the "more text". The problem is that the variable "string" is actually a huge file with a lot of weird characters inside of it.
I know i could change this example regex to:
.Pattern = "SUBSCRIBER\s+ID:\s+(\d+).*"
and that would work in this example, but the file I am using has a lot of characters that ".*" do not match, such as special characters, tabs, newlines.
Is there a way to only access $1 without using the Replace method?
maybe something like:
Set SubscriberID = SubsriberRegEx.Execute(string).$1
Any help would be much appreciated.