Lugaru's Epsilon
Programmer's
Editor

Context:
Epsilon User's Manual and Reference
   Commands by Topic
      Changing Text
         . . .
         Replacing
         Regular Expressions
            . . .
            Searching Rules
            Regular Expression Assertions
            Regular Expression Commands
         Rearranging
            Sorting
            Transposing
            Formatting Text
         . . .

Previous   Up    Next
Regular Expression Assertions  Commands by Topic   Sorting


Epsilon User's Manual and Reference > Commands by Topic > Changing Text > Regular Expressions >

Regular Expression Commands

You can invoke a forward regex search with the Ctrl-Alt-S key, which runs the command regex-search. The Ctrl-Alt-R key invokes a reverse incremental search. You can also enter regular expression mode from any search prompt by typing Ctrl-T to that prompt. For example, if you press Ctrl-S to invoke incremental-search, pressing Ctrl-T causes it to enter regular expression mode. See Searching for a description of the searching commands.

The key Alt-* runs the command regex-replace. This command works like the command query-replace, but interprets its search string as a regular expression.

In the replacement text of a regex replace, the # character followed by a digit n has a special meaning in the replacement text. Epsilon finds the nth parenthesized expression in the pattern, counting left parentheses from 1. It then substitutes the match of this subpattern for the #n in the replacement text. For example, replacing

([a-zA-Z0-9_]+) = ([a-zA-Z0-9_]+)

with

#2 := #1

changes

variable = value;

to

value := variable;

If #0 appears in the replacement text, Epsilon substitutes the entire match for the search string. To include the actual character # in a replacement text, use ##. In a search pattern, you can follow the open parenthesis with ?: to tell Epsilon not to count it for replacement purposes; that pair of parentheses will only be used for grouping.

The replacement text can use the syntax #U to force the rest of the replacement to uppercase (including text substituted from the match using #1 syntax). Using #L or #C forces the remaining text to lowercase, or capitalizes it, respectively. Using #E marks the end of such case modifications; the following replacement text will be substituted as-is. For instance, searching for "(<word>+) by (<word>+)" and replacing it with "#L#2#E By #U#1" will change the match "Two by Four" into "four By TWO".

When the search string consists of multiple words of literal text separated by the | character, you can use #S in the replacement text to swap them. For instance, if you search for dog|cat and replace it with #S, Epsilon replaces instances of dog with cat, and instances of cat with dog. If you have more than two choices, each choice will be replaced by the next choice in the list.

When you don't use the above syntax, replacing preserves the case of each match according to specific rules. See the replace-by-case variable for details.

Characters other than # in the replacement text have no special meaning. To enter special characters, type a Ctrl-Q before each. Type Ctrl-Q Ctrl-J to include a <Newline> character in the replacement text. Or specific characters in the replacement text by name, using the syntax #<Newline>, or by number, such as #<#0x221a> for the Unicode square root character.

Standard bindings:

  Ctrl-Alt-S  regex-search
 Ctrl-Alt-R  reverse-regex-search
 Alt-*  regex-replace
 



Previous   Up    Next
Regular Expression Assertions  Commands by Topic   Sorting


Lugaru Copyright (C) 1984, 2012 Lugaru Software Ltd. All Rights Reserved.