Interactive Writing of Regular Expressions
For example, the buffer contains a string.
ABCD 3
Run the following command:
M-X: Re-Builder
A small buffer is displayed. Enter the regular expression D in double quotation marks. The buffer on the string is immediately highlighted with the D character. If the input is 3, the buffer is highlighted with three characters.
Special characters
Reference: http://www.gnu.org/software/emacs/manual/html_node/elisp/Regexp-Special.html#Regexp-Special
'.' Represents any character (except the line break), so "a. c" can match ABC in ABCD 3.
'*' Indicates that the previous character (string) can be repeated> = 0
For example, "E *" can also match ABCD 3 in re-builder, which may lead to confusion and is generally not used in this way.
In addition, if multiple characters are followed by *, as long as one character can be matched, this is a thing that does not know where it is used.
We recommend that you try not to use this.
If * is used at the beginning, it can only represent normal characters. The same situation applies to + and ?, In a word, special characters can only be used as common characters if they are not possible.
'+' Indicates that the previous character (string) must appear at least once.
For example, "BC + D" matches the above string ABCD 3
'? 'Indicates that the previous character (string) appears once or 0 times
'^' Matches the start of a string
'&' Matches the end of a string
[...] Can contain several characters, as long as it matches one of them.
For example, the string ABCD 3 AB
Use the regular expression "[BC]" to match three values: B c and the last B.
[^...] Indicates that it cannot contain any character in [].
\ Indicates that the special character following it is only a common character.
Note: To match the \ character in a string, four \ characters are required, for example, ABCD 3 AB \ EF.
Regular Expression :"\\\\"
First, because the \ in the double quotation marks is not displayed in the elisp string writing method, to display it, it must be two \
Then, in the regular expression syntax, \ is a special character, \ can represent \,
Therefore, "\\\\" is a logical regular expression "\\", so it matches the character \
'*? ''+? ''?? 'And' * '+ ''? 'Similar functions, only non-Greedy matching, only matching the most appropriate one.