468,541 Members | 1,812 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,541 developers. It's quick & easy.

ASP Regular Expression Help

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.
May 13 '10 #1
1 1673
jhardman
3,405 Expert 2GB
is there any way to narrow down how many characters the id will be? is there always a space after it? Is there ever a space in the midst of the ID?

Jared
May 17 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Reckless | last post: by
5 posts views Thread by Ian Richardson | last post: by
6 posts views Thread by JohnSouth | last post: by
6 posts views Thread by dotnetprogram | last post: by
9 posts views Thread by Schorschi | last post: by
3 posts views Thread by rodchar | last post: by
3 posts views Thread by Zach | last post: by
14 posts views Thread by Chris | last post: by
9 posts views Thread by Rene | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.