What is Regex Perl

Perl Regular Expressions

with special consideration of the index search in the WWW.

Normal characters: Letters A-Za-z, digits 0-9, some special characters like _-, '. Each In Perl (!), Special characters get their normal meaning as characters if a "backslash" \ is placed in front of them.

Note: When searching for an index on the WWW (cgi-bin), the space '' is internally replaced by a plus sign '+'. Enter the space as or, the plus sign as, a period as. You get the complete list if you just enter a point '' in the search field.

Search: Meta characters with special meaning

^
Beginning of line (e.g .: ^ beginning)
$
End of line (ex .: end $)
|
Alternative ("or", e.g. chemistry | physics)
.
any character (except the line end marker)
*
Repetition of the last character (including none, so the character does not need to be present)
.*
any character string (e.g. ^. * $ fits any line)
+
Repetition of the last character (present at least once)
?
the last character must appear once or not at all
{n}{n, m}
the last character must n times or n to m occur times (e.g. W {3} corresponds to WWW)
\ w
alphanumeric character including _
\ W
non-alphanumeric character (including space)
\ b
Word boundary ("boundary", e.g .: \ bin \ b the word 'in')
\ B
no word boundary ("non-boundary")
\ d
Digit
\ D
no digit
\ s
Interspace ("whitespace")
\ S
no space ("non-whitespace")
[...]
Character class, e.g. [A-H] letters A to H
[^...]
Exclusion of a character class, e.g. [^ A-H] any character except a letter A to H

\ n \ r \ f \ t \nnn
LF CR FF HT Octal code
(...)
Marking of a substring. Inside a pattern you can (e.g.) refer to it with \ 1, outside with $ 1 (generally \n or $n).

Examples for the WWW index search

Output of the complete list (any character is searched for)
'FU' as a word
'Chemistry' or 'Physics'
'Chemistry' and 'Physics' (in any order)
fits e.g. for 'ftp-server' or 'ftp server'
only fits 'ftp server'
stands for WWW
fits 'behavior' or 'behavior'

Search and replace

n
n-th substring (substring, "bracket")
last matching substring (substring, "bracket")
entire matching string
everything before the matching string
everything after the appropriate string

Burkhard Kirste, 1994/04/12