Some Regular Expression Metacharacters : Metacharacters « Regular Expression « Perl






Some Regular Expression Metacharacters

    

Metacharacter   Represents
^               Matches at the beginning of a line
$               Matches at the end of a line
a.c             Matches an 'a', any single character, and a 'c'
[abc]           Matches an 'a' or 'b' or 'c'
[^abc]          Matches a character that is not an 'a' or 'b' or 'c'
[0-9]           Matches one digit between '0' and '9'
ab*c            Matches an 'a', followed by zero or more 'b's and a 'c'
ab+c            Matches an 'a', followed by one or more 'b's and a 'c'
ab?c            Matches an 'a', followed by zero or one 'b' and a 'c'
(ab)+c          Matches one or more occurrences of 'ab' followed by a 'c'
(ab)(c)         Captures 'ab' and assigns it to $1, captures 'c' and assigns it to $2.

   
    
    
    
  








Related examples in the same category

1.Meta-Character ASCII Values
2.Meta-Characters listing
3.Metacharacters and metasymbols
4.Metacharacters for Single Characters
5.Metacharacters that Turn off Greediness
6..* special-character combination tries to match as much as possible
7.The dot metacharacter
8.The dot metacharacter and the zero or more quantifier