LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

perlre

documents Perl regular expressions, one of the most powerful regex

TLDR

View Perl regex documentation
$ perldoc perlre
copy
View quick reference
$ perldoc perlreref
copy
View regex tutorial
$ perldoc perlretut
copy
View character classes
$ perldoc perlrecharclass
copy

SYNOPSIS

perldoc perlre

DESCRIPTION

perlre documents Perl regular expressions, one of the most powerful regex implementations. Perl's regex syntax influenced many other languages and tools (PCRE).

BASIC PATTERNS

$ /pattern/       # Match
s/old/new/      # Substitute
m/pattern/i     # Case insensitive
/pattern/g      # Global

# Character classes
\d  - Digit
\w  - Word character
\s  - Whitespace
.   - Any character
copy

MODIFIERS

$ /i  - Case insensitive
/g  - Global match
/m  - Multiline mode
/s  - Single line (. matches \n)
/x  - Extended (allow whitespace)
/o  - Compile once
copy

CAPTURES

$ # Match and capture
if ($text =~ /(\d+)/) {
    print "Found: $1\n";
}

# Named captures
/(?<name>\w+)/;
print $+{name};

# Non-greedy
/.*?/
copy

ADVANCED FEATURES

$ (?:...)   - Non-capturing group
(?=...)   - Positive lookahead
(?!...)   - Negative lookahead
(?<=...)  - Positive lookbehind
(?<!...)  - Negative lookbehind
(?>...)   - Atomic group
copy

CAVEATS

Complex regex can be slow. Use /x for readability. PCRE differs slightly from Perl regex.

HISTORY

Perl regular expressions were designed by Larry Wall and evolved through Perl versions, becoming the standard for modern regex.

SEE ALSO

perl(1), perldoc(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid