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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with REGEXP 1

Status
Not open for further replies.

elsenorjose

Technical User
Oct 29, 2003
684
0
0
US
Ok, so I searched the forum and I can't figure out how to modify something for my use. I'm having a hard time writing a regular expression in my query. Here's some sample data:


I'm trying to do a comparison of URLs that have query arguments after the 'portid:12345' section vs. URLs that don't. The 5 digits after 'portid:' will change so I can't just hard code

Code:
...url like '%portid:12345'

The good news is that's a pretty consistent pattern; in other words, portid: followed by 5 digits is how this appears in all URLs. Can someone help me with this?

Thanks.
 
You might try
Code:
... WHERE url REGEXP '%portid:[0-9]{5}%'
meaning the url matches the regular expression. The regular expression is intended to be
% = anything
portid: = exactly that, portid:
[0-9] = a number
{5} = repeated 5 times

This I gleaned from reading the following



I have no idea whether it will work.
 
Small tweak but I got it...

WHERE url REGEXP '/portid:[0-9]{5}$'

We had to indicate that it was at the end of the strong with the '$' sign and that portid was preceded by a '/'

Thanks for the brainstorm though!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top