Find this, but not this...
Posted: Mon May 29, 2006 10:37 am
Hi, having a bit of trouble finding some things in a given position, but not some things. For instance:
Lets take my regex expression up to the first double quote until the ending double quote...
So this will match anything in between the two quotes. However, I want whatever was used to surround the URL to not be included in the URL... for obvious reasons.
Now, I can hear you all shouting that a URL can only contain certain characters, so why not just test for those. However, the scenario this is going to be used in is slightly different in that the URL could be replaced by anything, possibly even single/double quotes.
Sooo, the URL should only not contain what it is being surrounded by essentially. I am sure there is an easy way to do this but it has escaped me for the time being.
Thanks for your help,
someberry
Code: Select all
<a href="http://www.domain.com">Code: Select all
(\"|\'|)([\w\W])*?\1Now, I can hear you all shouting that a URL can only contain certain characters, so why not just test for those. However, the scenario this is going to be used in is slightly different in that the URL could be replaced by anything, possibly even single/double quotes.
Sooo, the URL should only not contain what it is being surrounded by essentially. I am sure there is an easy way to do this but it has escaped me for the time being.
Thanks for your help,
someberry