I'm having trouble finding a regular expression that matches the following String.
Korben;http://feeds.feedburner.com/KorbensBlog-UpgradeYourMind?format=xml;1
One problem is escaping the question mark. Java's pattern matcher doesn't seem to accept \\?
as a valid escape sequence but it also fails to work with the tester at myregexp.com.
Here's what I have so far:
([a-zA-Z0-9])+;http://([a-zA-Z0-9./-]+);[0-9]+
Any suggestions?
Edit: The original intent was to match all URLs that could be found after the first semi colon.
If you are putting the expression in a string, you need to escape the "\\" as well. That is:
String expr = "([a-zA-Z0-9])+;http://([a-zA-Z0-9./\\-\\?]+);[0-9]+";
You also need to escape the "-" if it's not the last character in a character class ([...]) construct.
[?]
匹配“?”
Maybe you need to escape your backslash, if your expression is in a string. Something like "\\\\?"
([a-zA-Z0-9]+);http://([a-zA-Z0-9./-]+)(\?[^;]+);([0-9]+)
在那个RexExp编辑器网站上为我工作。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.