Regular expression for a hexadecimal number?

后端 未结 11 1623
旧巷少年郎
旧巷少年郎 2020-11-29 02:56

How do I create a regular expression that detects hexadecimal numbers in a text?

For example, ‘0x0f4’, ‘0acdadecf822eeff32aca5830e438cb54aa722e3’, and ‘8BADF00D’.

11条回答
  •  南方客
    南方客 (楼主)
    2020-11-29 03:47

    If you are looking for an specific hex character in the middle of the string, you can use "\xhh" where hh is the character in hexadecimal. I've tried and it works. I use framework for C++ Qt but it can solve problems in other cases, depends on the flavor you need to use (php, javascript, python , golang, etc.).

    This answer was taken from:http://ult-tex.net/info/perl/

提交回复
热议问题