Regex Question: Match if absent
-
hi there, I've got a regular expression which should match an url:
(http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?)
this is fine. but now I want to make sure, that the url is not enclosed by ". that means, thishttp://bla.com
should match,some text http://bla.com more text
should match as well but this"http://bla.com"
shouldn't. i've tried this, which doesn't work:[^"](http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?)[^"]
can anyone help? thanks in advance!/matthias
I love deadlines. I like the whooshing sound they make as they fly by.
[Douglas Adams] -
hi there, I've got a regular expression which should match an url:
(http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?)
this is fine. but now I want to make sure, that the url is not enclosed by ". that means, thishttp://bla.com
should match,some text http://bla.com more text
should match as well but this"http://bla.com"
shouldn't. i've tried this, which doesn't work:[^"](http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?)[^"]
can anyone help? thanks in advance!/matthias
I love deadlines. I like the whooshing sound they make as they fly by.
[Douglas Adams] -
([^\x22]http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?[^\x22])
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
thanks, this is it. well almost. the problem is, if I have a string which contains only an url, that is
http://bla.com
or a string which looks likepeter, look here:http://bla.com! have you seen?
they both don't work. in the first case, no match is returned, in the second one,:http://bla.com!
is returned instead ofhttp://bla.com
. If I start the regex with ([^\x22]**?**http\://... then again it will match the " as well. I'm getting grey hair on that one and would greatly appreciate further assistance./matthias
I love deadlines. I like the whooshing sound they make as they fly by.
[Douglas Adams] -
([^\x22]http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?[^\x22])
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
hey, I've tried to use some regular expressions as well today and had a real hard time finding out the correct expression. Do you have a good link or something that explains this? MSDN really s*cks on this. thanks
V. I found a living worth working for, but haven't found work worth living for.
-
hey, I've tried to use some regular expressions as well today and had a real hard time finding out the correct expression. Do you have a good link or something that explains this? MSDN really s*cks on this. thanks
V. I found a living worth working for, but haven't found work worth living for.
V. wrote:
MSDN really s*cks on this
I agree. But, unfortunately, at the moment, MSDN is my only reference on regular expressions. Ask here at CP, I think there are a lot of people far more experts than me about regular expressions. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.