I know this is a stupid question but I want to know what the meaning means in simple terms for each sequence below.
\[0-7]{1,3}
the sequence of characters matching the regular expression is a character in octal notation
\x[0-9A-Fa-f]{1,2}
the sequence of characters matching the regular expression is a character in hexadecimal notation
It means that if you have a string like "foo bar \041"
, \041
will be treated as octal representation of a character. Similar for the hexadecimal sequence.
The regular expressions define the structure the character sequences have to follow in order to be interpreted as octal or hex representation:
\
followed by one to three digits between 0
and 7
. \
followed by x
followed by one or two characters which can be either digits or upper or lower case letters.Have a look at the ASCII table to see each character's octal and hexadecimal equivalent.
For example:
echo "\064\062"; // echos 42
In hex:
echo "\x52\x50";