BlackBerry 6 Regex
I have a rege开发者_Python百科x for BlackBerry 6
Mozilla/5.0 (BlackBerry; U; BlackBerry (?'deviceName'\w+); en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/(?'version'(?'major'\d+)(.(?'minor'\d+)?)\w*) Mobile Safari/534.11+
But it doesn't seem to match this string:
Mozilla/5.0 (BlackBerry; U; BlackBerry AAAA; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/X.X.X.X Mobile Safari/534.11+
What's wrong? This is in the Browser Definition files for .NET 4.0
NOTE: For some reason the editor doesn't show my escaped characters either. all of the / are escaped.
Assuming your input string actually contains a numeric version, like 6.5.4.3
instead of X.X.X.X
, the following regex will match:
@"Mozilla\/5.0 \(BlackBerry; U; BlackBerry (?'deviceName'\w+); en-US\) AppleWebKit\/534\.11\+ \(KHTML, like Gecko\) Version\/(?'version'(?'major'\d+)(.(?'minor'\d+)?)[\.\w]*) Mobile Safari\/534\.11\+"
In addition of having to escape all /().+
characters, your regex didn't match the last two elements of the version number; since the \w
character class does not mactch period characters.
精彩评论