📄 nedit.doc
字号:
with. When a calltip is requested it won't match tips from languages other than the current language mode. Language blocks only affect the tips listed after the block. Alias blocks allow a calltip to have multiple keys. The first line of the block is the key for the calltip to be displayed, and the rest of the lines are additional keys, one per line, that should also show the calltip. Version blocks are ignored for the time being. You can use calltips in your own macros using the calltip() and kill_calltip() macro subroutines and the $calltip_ID macro variable. See the Macro Subroutines section for details. ===================REGULAR EXPRESSIONS===================-------------------------------BASIC REGULAR EXPRESSION SYNTAX------------------------------- Regular expressions (regex's) are useful as a way to match inexact sequences of characters. They can be used in the `Find...' and `Replace...' search dialogs and are at the core of Color Syntax Highlighting patterns. To specify a regular expression in a search dialog, simply click on the `Regular Expression' radio button in the dialog. A regex is a specification of a pattern to be matched in the searched text. This pattern consists of a sequence of tokens, each being able to match a single character or a sequence of characters in the text, or assert that a specific position within the text has been reached (the latter is called an anchor.) Tokens (also called atoms) can be modified by adding one of a number of special quantifier tokens immediately after the token. A quantifier token specifies how many times the previous token must be matched (see below.) Tokens can be grouped together using one of a number of grouping constructs, the most common being plain parentheses. Tokens that are grouped in this way are also collectively considered to be a regex atom, since this new larger atom may also be modified by a quantifier. A regex can also be organized into a list of alternatives by separating each alternative with pipe characters, `|'. This is called alternation. A match will be attempted for each alternative listed, in the order specified, until a match results or the list of alternatives is exhausted (see Alternation section below.) THE 'ANY' CHARACTER If a dot (`.') appears in a regex, it means to match any character exactly once. By default, dot will not match a newline character, but this behavior can be changed (see help topic Parenthetical Constructs, under the heading, Matching Newlines). CHARACTER CLASSES A character class, or range, matches exactly one character of text, but the candidates for matching are limited to those specified by the class. Classes come in two flavors as described below: [...] Regular class, match only characters listed. [^...] Negated class, match only characters NOT listed. As with the dot token, by default negated character classes do not match newline, but can be made to do so. The characters that are considered special within a class specification are different than the rest of regex syntax as follows. If the first character in a class is the `]' character (second character if the first character is `^') it is a literal character and part of the class character set. This also applies if the first or last character is `-'. Outside of these rules, two characters separated by `-' form a character range which includes all the characters between the two characters as well. For example, `[^f-j]' is the same as `[^fghij]' and means to match any character that is not `f', `g', `h', `i', or `j'. ANCHORS Anchors are assertions that you are at a very specific position within the search text. NEdit regular expressions support the following anchor tokens: ^ Beginning of line $ End of line < Left word boundary > Right word boundary \B Not a word boundary Note that the \B token ensures that the left and right characters are both delimiter characters, or that both left and right characters are non-delimiter characters. Currently word anchors check only one character, e.g. the left word anchor `<' only asserts that the left character is a word delimiter character. Similarly the right word anchor checks the right character. QUANTIFIERS Quantifiers specify how many times the previous regular expression atom may be matched in the search text. Some quantifiers can produce a large performance penalty, and can in some instances completely lock up NEdit. To prevent this, avoid nested quantifiers, especially those of the maximal matching type (see below.) The following quantifiers are maximal matching, or "greedy", in that they match as much text as possible. * Match zero or more + Match one or more ? Match zero or one The following quantifiers are minimal matching, or "lazy", in that they match as little text as possible. *? Match zero or more +? Match one or more ?? Match zero or one One final quantifier is the counting quantifier, or brace quantifier. It takes the following basic form: {min,max} Match from `min' to `max' times the previous regular expression atom. If `min' is omitted, it is assumed to be zero. If `max' is omitted, it is assumed to be infinity. Whether specified or assumed, `min' must be less than or equal to `max'. Note that both `min' and `max' are limited to 65535. If both are omitted, then the construct is the same as `*'. Note that `{,}' and `{}' are both valid brace constructs. A single number appearing without a comma, e.g. `{3}' is short for the `{min,min}' construct, or to match exactly `min' number of times. The quantifiers `{1}' and `{1,1}' are accepted by the syntax, but are optimized away since they mean to match exactly once, which is redundant information. Also, for efficiency, certain combinations of `min' and `max' are converted to either `*', `+', or `?' as follows: {} {,} {0,} * {1,} + {,1} {0,1} ? Note that {0} and {0,0} are meaningless and will generate an error message at regular expression compile time. Brace quantifiers can also be "lazy". For example {2,5}? would try to match 2 times if possible, and will only match 3, 4, or 5 times if that is what is necessary to achieve an overall match. ALTERNATION A series of alternative patterns to match can be specified by separating them with vertical pipes, `|'. An example of alternation would be `a|be|sea'. This will match `a', or `be', or `sea'. Each alternative can be an arbitrarily complex regular expression. The alternatives are attempted in the order specified. An empty alternative can be specified if desired, e.g. `a|b|'. Since an empty alternative can match nothingness (the empty string), this guarantees that the expression will match. COMMENTS Comments are of the form `(?#<comment text>)' and can be inserted anywhere and have no effect on the execution of the regular expression. They can be handy for documenting very complex regular expressions. Note that a comment begins with `(?#' and ends at the first occurrence of an ending parenthesis, or the end of the regular expression... period. Comments do not recognize any escape sequences. --------------METACHARACTERS-------------- ESCAPING METACHARACTERS In a regular expression (regex), most ordinary characters match themselves. For example, `ab%' would match anywhere `a' followed by `b' followed by `%' appeared in the text. Other characters don't match themselves, but are metacharacters. For example, backslash is a special metacharacter which 'escapes' or changes the meaning of the character following it. Thus, to match a literal backslash would require a regular expression to have two backslashes in sequence. NEdit provides the following escape sequences so that metacharacters that are used by the regex syntax can be specified as ordinary characters. \( \) \- \[ \] \< \> \{ \} \. \| \^ \$ \* \+ \? \& \\ SPECIAL CONTROL CHARACTERS There are some special characters that are difficult or impossible to type. Many of these characters can be constructed as a sort of metacharacter or sequence by preceding a literal character with a backslash. NEdit recognizes the following special character sequences: \a alert (bell) \b backspace \e ASCII escape character (***) \f form feed (new page) \n newline \r carriage return \t horizontal tab \v vertical tab *** For environments that use the EBCDIC character set, when compiling NEdit set the EBCDIC_CHARSET compiler symbol to get the EBCDIC equivalent escape character.) OCTAL AND HEX ESCAPE SEQUENCES Any ASCII (or EBCDIC) character, except null, can be specified by using either an octal escape or a hexadecimal escape, each beginning with \0 or \x (or \X), respectively. For example, \052 and \X2A both specify the `*' character. Escapes for null (\00 or \x0) are not valid and will generate an error message. Also, any escape that exceeds \0377 or \xFF will either cause an error or have any additional character(s) interpreted literally. For example, \0777 will be interpreted as \077 (a `?' character) followed by `7' since \0777 is greater than \0377. An invalid digit will also end an octal or hexadecimal escape. For example, \091 will cause an error since `9' is not within an octal escape's range of allowable digits (0-7) and truncation before the `9' yields \0 which is invalid. SHORTCUT ESCAPE SEQUENCES NEdit defines some escape sequences that are handy shortcuts for commonly used character classes. \d digits 0-9 \l letters a-z, A-Z, and locale dependent letters \s whitespace \t, \r, \v, \f, and space \w word characters letters, digits, and underscore, `_' \D, \L, \S, and \W are the same as the lowercase versions except that the resulting character class is negated. For example, \d is equivalent to `[0-9]', while \D is equivalent to `[^0-9]'. These escape sequences can also be used within a character class. For example, `[\l_]' is the same as `[a-zA-Z_]', extended with possible locale dependent letters. The escape sequences for special characters, and octal and hexadecimal escapes are also valid within a class. WORD DELIMITER TOKENS Although not strictly a character class, the following escape sequences behave similarly to character classes: \y Word delimiter character \Y Not a word delimiter character The `\y' token matches any single character that is one of the characters that NEdit recognizes as a word delimiter character, while the `\Y' token matches any character that is NOT a word delimiter character. Word delimiter characters are dynamic in nature, meaning that the user can change them through preference settings. For this reason, they must be handled differently by the regular expression engine. As a consequence of this, `\y' and `\Y' can not be used within a character class specification. ------------------------PARENTHETICAL CONSTRUCTS------------------------ CAPTURING PARENTHESES Capturing Parentheses are of the form `(<regex>)' and can be used to group arbitrarily complex regular expressions. Parentheses can be nested, but the total number of parentheses, nested or otherwise, is limited to 50 pairs. The text that is matched by the regular expression between a matched set of parentheses is
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -