Help me with my regex
-
I'm trying to write a regex using Regex++ with C++ to match on URLs. The regex I'm using is It's weird ... it seems to work for: and but not for Any ideas why it wouldn't match on the second one, or anyone have a better pattern-matcher for URLs? Thanks
-
I'm trying to write a regex using Regex++ with C++ to match on URLs. The regex I'm using is It's weird ... it seems to work for: and but not for Any ideas why it wouldn't match on the second one, or anyone have a better pattern-matcher for URLs? Thanks
I don't know Regex++, but I know Perl regexes and going on that knowledge, I think you have a mistake in your slash escaping.
[=\\w\\d\./\/\\-\?]*
The part after the\.
is suspicious. There's a slash, followed by an escaped slash. I'd start by taking out the slash right after the dot. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Pinky, are you pondering what I'm pondering? I think so Brain, but if we shaved our heads, we'd look like weasels! -
I don't know Regex++, but I know Perl regexes and going on that knowledge, I think you have a mistake in your slash escaping.
[=\\w\\d\./\/\\-\?]*
The part after the\.
is suspicious. There's a slash, followed by an escaped slash. I'd start by taking out the slash right after the dot. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Pinky, are you pondering what I'm pondering? I think so Brain, but if we shaved our heads, we'd look like weasels!Thanks for your response. I ended up drastically simplifying my regex by controlling the greedyness. In the end, I ended up with: Thanks again. It's been awhile since I've dealt with regexes, and I'm definitely out of practice.