BJ Dela Cruz
BJ Dela Cruz

Reputation: 5354

Please explain this Java regex

I didn't write the following regex, and I'm trying to figure out what it does. I know that it must begin with policy-map and must have at least one space between policy-map and whatever comes next. But I'm stuck trying to figure out what the stuff inside the parenthesis means. I know that whatever it is, it has to be at the end of the line.

^policy-map\\s+([\\x21-\\x7e]{1,40})$

Thanks!

Upvotes: 3

Views: 2981

Answers (3)

burning_LEGION
burning_LEGION

Reputation: 13460

^ begin of string

policy-map constant

\s+ spaces

([\x21-\x7e]{1,40}) 1-40 symbols from \x21 to \x7e (i.e. all printable, non-whitespace ASCII characters including punctuation, upper and lower case letters and numbers)

$ end of string

Upvotes: 8

MRAB
MRAB

Reputation: 20664

^              Start of string
policy-map     "policy-map"
\\s+           One or more whitespace characters
(              Start of capture group 1
[\\x21-\\x7e]  From 1 to 40 characters in the range '\x21' to '\7E'
)              End of capture group 1
$              End of string

Upvotes: 7

Michael Krelin - hacker
Michael Krelin - hacker

Reputation: 143299

characters in range from hex 21 to hex 7e (basically printable, non-whitespace ascii) 1 to 40 times.

Upvotes: 13

Related Questions