Regular regex posix standard, gnu extension, and PC compatibility

Source: Internet
Author: User
Tags posix regular expression

A regular expression is a logical formula for string operations. It uses predefined characters and combinations of these specific characters to form a "rule string ", this "rule string" is used to express a filtering logic for strings.
Given a regular expression and another string, we can achieve the following goals:
1. Whether the given string conforms to the filtering logic of the regular expression (called "match ");
2. You can use a regular expression to obtain the desired part from the string.
Regular expressions are characterized:
1. Strong flexibility, logic, and functionality;
2. You can quickly implement complex string control in an extremely simple way.
3. It is difficult for new contacts.
Because regular expressions are mainly applied to text, they are used in various text editors, from the famous editor EditPlus to the large editor such as Microsoft Word and Visual Studio, you can use regular expressions to process text content.

The posix standard of regex (Regular Expression) complies with the unix platform. gnu has made a lot of extensions to regex to make regex easier to use, but not all platforms support gnu extensions.

The Mac OS x platform only supports the posix standard, but does not support the gnu extension. Therefore, when running the gnu extension script on Mac OS X platform, compatibility issues may occur.

For example, the \ s extension that matches all white spaces is gnu extension. To match all white spaces on Mac OS X, use [[: space:].

Below are some common posix expressions corresponding to GNU extensions:
\ W-[[: alnum:] _]
\ W-[^ [: alnum:] _]
\ S-[[: space:]
\ S-[^ [: space:]

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.