3

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!

2
  • 1
    What's the question then? "Explain this regex in detail?" Commented Jul 17, 2012 at 19:02
  • I highly recommend the following site: regex101.com/r/gV1hK3 Commented Oct 1, 2012 at 11:00

3 Answers 3

13

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

Sign up to request clarification or add additional context in comments.

2 Comments

[\\x21-\\x7e] is commonly used to describe alphanumeric+special chars
This is the first time I've seen a regular expression written using hex. Thanks for your answer!
8

^ 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

Comments

7
^              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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.