Hexadecimal regular matching _ regular expressions in programming languages

Source: Internet
Author: User
It is made up of 0-9,a-f. The corresponding relationship with the 10 binary is: 0-9 corresponds to 0-9; A-f corresponds to 10-15; The number of N-ary can be expressed in 0---(N-1) for more than 9 letters A-F.

Which is made up of characters: 012345679ABCDEF

The number 16 in C language must begin with 0x. For example, 0x1 represents a 16 number. and 1 represents a decimal. In addition, such as: 0xff,0xff,0x102a, and so on. The x is not case-sensitive. (Note: 0 of the 0x is the number 0, not the letter O)

So the regular matching of programming languages such as C or C + + is:
Copy Code code as follows:

\b0[xx][0-9a-fa-f]+\b

He can match.
Copy Code code as follows:

0xDEADBEEF
0xdeadbeef
0XDEADBEEF
0Xdeadbeef
0x12345678

Can not match
Copy Code code as follows:

12345678
Deadbeef

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.