I am trying the following code
d := []byte(\"\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x80J\\x13\\x80SQ\\x80L\\xe0\\x80@\\x92\\x80L?\\x80H\\xe0\")
When you use \
in a string, it signals an escape character sequence. The string itself does not appear as \x01...
, but instead, each of these chunks is converted into a single character.
That is to say that your regex is attempting to match the unprocessed string's value and not the actual string value stored in d
.
I'm not sure how to improve your regular expression since it isn't clear to me what you expect it to match. Currently, it appears that you are attempting to validate that the byte array was instantiated using a specific method instead of by setting bytes to integers. If you can better articulate the aim of your regex, I may be able to provide assistance further.
Look at the different kinds of string literals in the Go documentation.
You probably want to use the back-ticks (`) for a "raw_string_lit" in your first string.