Escape sequence - Character in hexadecimal \x.. \x{..}

Q

What is the escape sequence for a character written in hexadecimal format?

How to write a regular expression to capture the escape (Backslash) \ character in a string like: \x5C

✍: FYIcenter.com

A

The escape sequence for any character in hexadecimal format is '\x..' or \x{..}, '..' is the 2 hexadecimal digits. For example:

\x33   - matches '3' character
\x0D   - matches the Carriage Return character
\x{0A}   - matches the Line Feed character

The regular expression to capture the escape \ character is:

\x5C

\x5C   - matches the Backslash character \ using hexadecimal digits

Click the button to test this regular expression here online:

2013-01-26, 0👍, 0💬