|
-
Jul 29th, 2009, 05:58 AM
#1
Thread Starter
Hyperactive Member
Regex help
Hi Guys,
I am trying to use a regular expression to find a certain string within a textbox.
Is it possible to include the equals sign (=) within the regex so it looks for this? When i type the equals sign within the regex it doesn't fnid it any more.
Works when searching this string - "and JobID 816138</Detail>":
Code:
Dim MatchJobId As System.Text.RegularExpressions.MatchCollection = System.Text.RegularExpressions.Regex.Matches(MyResults, "(?<=and JobID ).+?(?=</Detail>)", System.Text.RegularExpressions.RegexOptions.Singleline)
Don't Work when searching "?JobID=816138</Detail>":
Code:
Dim MatchJobId As System.Text.RegularExpressions.MatchCollection = System.Text.RegularExpressions.Regex.Matches(MyResults, "(?<=?JobID=).+?(?=</Detail>)", System.Text.RegularExpressions.RegexOptions.Singleline)
Do i have to use different characters for the = and ? sign when they are being included within the regex search?
Thanks,
Chloe ~X~
-
Jul 29th, 2009, 06:12 AM
#2
Re: Regex help
I think you'll need to use the bar (\) for those chars...
Rate People That Helped You
Mark Thread Resolved When Resolved
-
Jul 29th, 2009, 06:22 AM
#3
Re: Regex help
did that help?
the \ character is an escape character
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 29th, 2009, 06:45 AM
#4
Re: Regex help
have a look there : http://msdn.microsoft.com/en-us/library/1400241x%28VS.85%29.aspx It was very helpful to me when I had to work with regular expressions.
The "=" character is used for Positive lookahead so escaping it with the backslash character as previously suggested should work for that.
Your problem might also come from the "?" character which is a Metacharacter
Alex
.NET developer
"No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)
Things to consider before posting.
Don't forget to rate the posts if they helped and mark thread as resolved when they are.
.Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
My fresh new blog : writingthecode, even if I don't post much.
System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|