Elisp programming 12: Regular Expression 2

Source: Internet
Author: User

Character Type

Reference: http://www.gnu.org/software/emacs/manual/html_node/elisp/Char-Classes.html#Char-Classes

When using the character category, you need to add the upper brackets, such as the string: ABCD 3 AB \ ef

To match the numbers, use the character category.: [: Digit:]

The regular expression is written as follows: "[[: digit:]"

[: Xdigit:] used to match hexadecimal numbers

Forward-sentence command


Run the command: Forward-sentence to find the last position (end of the sentence) of the current sentence. Generally, the sentence is a full stop. question mark? Exclamation point! End. However, these symbols may appear in sentences.


For example, if the following sentence uses the forward-sentence command, you can still find the correct end of the sentence.


Hello, world dr. Mark make.


Emacs also provides the m-e shortcut.


Logic or


| The symbol must also use the \ prefix, so it is written as \ |


For example, the string is ABCD 3 AB \ EF.


The following regular expression can be used to match three sub-strings: AB cd AB.


"AB \ | cd"


The reason \ is restricted by the Emacs string syntax. The previous article has already been introduced.


Matching Group


() The matching group is represented by parentheses, but (and) is a special character. Use \ to indicate that it is not used as a special character. However, "\" is a special character and must be preceded by "\". Do not use it as a special character. Therefore


Is written as: \ (and \\)


For example, the regular "\ (AB \ | cd \)" matches the logic or string above and finds the first substring "ABCD"


For more advanced application Reference documents:


Http://www.gnu.org/software/emacs/manual/html_node/elisp/Regexp-Backslash.html#Regexp-Backslash


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.