elks-enhanced
public
Read
Owner: themaster
Branch: master
Commits: 6893
Updated: 2026-04-19 00:15
Git CLI clone URL
git clone https://www.xt-emporium.com/git/elks-enhanced.git
Fullscreen desktop URL
Code
Commits
History
Branches
Bug Reports
Discussions
Compare
Settings
elks-enhanced
/
elkscmd
/
elvis
/
doc
/
regexp.doc
File editor
Elvis 1.4 REGULAR EXPRESSIONS Page 4-1 E4. REGULAR EXPRESSIONSF Elvis uses regular expressions for searching and substututions. E4.1 SyntaxF Elvis' regexp package treats the following one- or two-character strings (called meta-characters) in special ways: \( \) Used to delimit subexpressions ^ Matches the beginning of a line $ Matches the end of a line \< Matches the beginning of a word \> Matches the end of a word [ ] Matches any single character inside the brackets * The preceding may be repeated 0 or more times \+ The preceding may be repeated 1 or more times \? The preceding is optional Anything else is treated as a normal character which must match exactly. The special strings may all be preceded by a backslash to force them to be treated normally. E4.2 OptionsF Elvis has two options which affect the way regular expressions are used. These options may be examined or set via the :set command. The first option is called "[no]magic". This is a boolean option, and it is "magic" (TRUE) by default. While in magic mode, all of the meta-characters behave as described above. In nomagic mode, only ^ and $ retain their special meaning. The second option is called "[no]ignorecase". This is a boolean option, and it is "noignorecase" (FALSE) by default. While in ignorecase mode, the searching mechanism will not distinguish between an uppercase letter and its lowercase form. In noignorecase mode, uppercase and lowercase are treated as being different. Also, the "[no]wrapscan" option affects searches. E4.3 SubstitutionsF The :s command has at least two arguments: a regular expression, and a substitution string. The text that matched the regular expression is replaced by text which is derived from the substitution string. Elvis 1.4 REGULAR EXPRESSIONS Page 4-2 Most characters in the substitution string are copied into the text literally but a few have special meaning: & Insert a copy of the original text ~ Insert a copy of the previous replacement text \1 Insert a copy of that portion of the original text which matched the first set of \( \) parentheses. \2 - \9 Does the same for the second (etc.) pair of \( \). \U Convert all chars of any later &, ~, or \# to uppercase \L Convert all chars of any later &, ~, or \# to lowercase \E End the effect of \U or \L \u Convert the first char of the next &, ~ or \# to uppercase \l Convert the first char of the next &, ~ or \# to lowercase These may be preceded by a backslash to force them to be treated normally. If "nomagic" mode is in effect, then & and ~ will be treated normally, and you must write them as \& and \~ form them to have special meaning. E4.4 ExamplesF This example changes every occurence of "utilize" to "use": :%s/utilize/use/g This example deletes all whitespace that occurs at the end of a line anywhere in the file. (The brackets contain a single space and a single tab.): :%s/[ ]\+$// This example converts the current line to uppercase: :s/.*/\U&/ This example underlines each letter in the current line, by changing it into an "underscore backspace letter" sequence. (The ^H is entered as "control-V backspace".): :s/[a-zA-Z]/_^H&/g This example locates the last colon in a line, and swaps the text before the colon with the text after the colon. The first \( \) pair is used to delineate the stuff before the colon, and the second pair delineates the stuff after. In the substitution text, \1 and \2 are given in reverse order, to perform the swap: :s/\(.*\):\(.*\)/\2:\1/
Commit message
This repository is read-only for this account.
Repository snapshot
Current branch
master
Visibility
public
Your access
Read
Remote
Configured
File activity
View file history