mIRC Home    About    Download    Register    News    Help

Print Thread
#98546 24/09/04 01:51 PM
Joined: Sep 2004
Posts: 7
I
ircbum Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
I
Joined: Sep 2004
Posts: 7
Hey all, I am having a little trouble with my regular expression.
(I am programming in Java)

does anyone know why my regular expression:
p = Pattern.compile("«\\d+\\s(mb|m|meg|k|kb|gb|gig|g)»",Pattern.CASE_INSENSITIVE);

will not match this text?
«150 MB»

Thanks! I am stumped
confused

#98547 25/09/04 04:28 AM
Joined: Apr 2004
Posts: 48
L
Ameglian cow
Offline
Ameglian cow
L
Joined: Apr 2004
Posts: 48
i think that you should use \d instead of \\d (and \s instead of \\s)

\\ = 'escaped' \, an \ without its proprieties


__________
dark_light @ irc.brasnet.org
#98548 25/09/04 10:54 AM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
There's two levels of parsing going on and backslash is the escape character in both of them. The extra backslashes are to escape the other backslashes when the string is parsed so that they're still backslash literals when the regular expression is parsed.


Spelling mistakes, grammatical errors, and stupid comments are intentional.

Link Copied to Clipboard