Metacharacters

Qedit supports the following metacharacters:

^ Start-of-line anchor
$ End-of-line anchor
. Matches any character
? Optional character
* Matches zero or more of the preceding character
+ Matches one or more of the preceding character
[ Start a character class
] End a character class
^ If first character in character class, negate class
( Subpattern start
) Subpattern end

Anchor Characters.

In general, a regexp can find a match anywhere in the text as long as it appears on a single line. There are two exceptions to this rule. The start-of-line (^) and the end-of-line ($) anchors. They are called anchors for very good reasons. These anchors actually indicate that the match must occur at fixed positions within the line.

The start-of-line anchor specifies that the string must appear at the very beginning of the line. If you enter

  ^abc  

the line will be selected only if the string “abc” is the first thing on the line. Thus,

  abcdefghij         {will be selected}  xyzabc             {will not be selected}  

Similarly, the end-of-line anchor specifies that the string must appear as the last thing on the line. In this example,

  abc$  

the lines must end with the string “abc.” There must not be anything else after it, not even spaces.

  abcdef             {will not be selected}  xyzabc             {will be selected}  

You can combine the anchors to verify that lines contain only a certain string and nothing else. Simply use

  ^abc$  

Every line has a start and an end anchor. If you search for the start or the end anchor (^ or $) by itself, Qedit matches all the lines in the file.

TIP: If you edit your file in full-screen mode with Set Visual Home Off, searching for the start-of-line anchor moves to the next line and puts the cursor at the first position. If you search for the end-of-line anchor, Qedit goes to the next line and puts the cursor after the last character on the line (if the last character is visible).

If the anchor characters are used anywhere else, they lose their metacharacter status and become ordinary characters.

Match Any Character.

The period, or dot, is used to match any character. The character can be of any type. As long as there is something in that position, there will be a match. For example,

  abc.xyz  

selects any line that contains the strings “abc” and “xyz” separated by a single character. That character can be anything (e.g., 1, w, #, etc).

Optional Character.

You can check the absence or presence of a character by following it with a question mark (?). In a regexp, the question mark indicates that the preceding character is optional. If it is present, it must appear only once.

  ab?c      {matches only "ac" and "abc"}  

Repeating Characters.

There are different ways you can check for the repetition of characters. If there is potential for a character to appear more than once, you can use the asterisk (*) or the plus sign (+) quantifier. These quantifiers are applied only to the character to their immediate left.

There is a very small difference between the two quantifiers. The asterisk represents zero or more occurrences of the preceding character. In other words, the character is optional, but, if it is there, it can appear multiple times. The plus sign represents one or more occurrences. This means the character must appear at least once, but it can appear multiple times.

  ab*c      {matches "ac," "abc," "abbc," etc.}  ab+c      {matches "abc," "abbc," but not "ac"}  

Metacharacters