The editor can search and replace text using regular expressions. A regular expression is a string that uses special characters to describe and reference patterns of text. The regular expression system used by the editor is modeled on Perl's regexp language. For more information on regular expressions, see Mastering Regular Expressions, Jeffrey E F Freidl, ISBN 0596002890.

Summary of special characters

The following table summarizes the special characters the SEGGER Embedded Studio editor supports

Pattern Description
\d Match a numeric character.
\D Match a non-numeric character.
\s Match a whitespace character.
\S Match a non-whitespace character.
\w Match a word character.
\W Match a non-word character.
[c] Match set of characters; e.g., [ch] matches characters c or h. A range can be specified using the ‘-’ character; e.g., ‘[0-27-9]’ matches if the character is 0, 1, 2, 7 8, or 9. A range can be negated using the ‘^’ character; e.g., ‘[^a-z]’ matches if the character is anything other than a lowercase alphabetic character.
\c Match the literal character c. For example, you would use ‘\\*’ to match the character ‘*’.
\a Match ASCII bell character (ASCII code 7).
\f Match ASCII form feed character (ASCII code 12).
\n Match ASCII line feed character (ASCII code 10).
\r Match ASCII carriage return character (ASCII code 13).
\t Match ASCII horizontal tab character (ASCII code 9).
\v Match ASCII vertical tab character.
\xhhhh Match Unicode character specified by hexadecimal number hhhh.
. Match any character.
* Match zero or more occurrences of the preceding expression.
+ Match one or more occurrences of the preceding expression.
? Match zero or one occurrences of the preceding expression.
{n} Match n occurrences of the preceding expression.
{n,} Match at least n occurrences of the preceding expression.
{,m} Match at most m occurrences of the preceding expression.
{n,m}Match at least n and at most m occurrences of the preceding expression.
^ Beginning of line.
$ End of line.
\b Word boundary.
\B Non-word boundary.
(e) Capture expression e.
\n Back-reference to nth captured text.
Examples

The following regular expressions can be used with the editor's search-and-replace operations. To use the regular expression mode, the Use regular expression checkbox must be set in the search-and-replace dialog. Once enabled, regular expressions can be used in the Find what search string. The Replace With strings can use the "n" back-reference string to reference any captured strings.

"Find what" "Replace With" Description
u\w.d Search for any-length string containing one or more word characters beginning with the character ‘u’ and ending in the character ‘d’.
^.*;$ Search for any lines ending in a semicolon.
(typedef.+\s+)(\S+); \1TEST_\2; Find C type definition and insert the string ‘TEST’ onto the beginning of the type name.