Changes

From SME Server
Jump to navigationJump to search
374 bytes added ,  16:24, 28 December 2013
Line 388: Line 388:  
=== Regular expressions ===
 
=== Regular expressions ===
   −
Perl's regular expression support is both broad and deep, and is the subject of lengthy documentation in perlrequick, perlretut, and elsewhere. However, in short:
+
Perl's regular expression support is both broad and deep, and is the subject of lengthy documentation in [http://perldoc.perl.org/perlrequick.html perlrequick], [http://perldoc.perl.org/perlretut.html perlretut], and elsewhere. However, in short:
    
==== Simple matching ====
 
==== Simple matching ====
Line 395: Line 395:  
         if ($a =~ /foo/) { ... } # true if $a contains "foo"
 
         if ($a =~ /foo/) { ... } # true if $a contains "foo"
   −
    The // matching operator is documented in perlop. It operates on $_ by default, or can be bound to another variable using the =~ binding operator (also documented in perlop).
+
The '''//''' matching operator is documented in [http://perldoc.perl.org/perlop.html perlop]. It operates on '''$_''' by default, or can be bound to another variable using the '''=~''' binding operator (also documented in [http://perldoc.perl.org/perlop.html perlop]).
 
==== Simple substitution ====
 
==== Simple substitution ====
   Line 403: Line 403:  
         # in $a
 
         # in $a
   −
    The s/// substitution operator is documented in perlop.
+
The '''s///''' substitution operator is documented in [http://perldoc.perl.org/perlop.html perlop].
 
==== More complex regular expressions ====
 
==== More complex regular expressions ====
   −
    You don't just have to match on fixed strings. In fact, you can match on just about anything you could dream of by using more complex regular expressions. These are documented at great length in perlre, but for the meantime, here's a quick cheat sheet:
+
You don't just have to match on fixed strings. In fact, you can match on just about anything you could dream of by using more complex regular expressions. These are documented at great length in [http://perldoc.perl.org/perlre.html perlre], but for the meantime, here's a quick cheat sheet:
    
         . a single character
 
         . a single character
Line 449: Line 449:  
==== Parentheses for capturing ====
 
==== Parentheses for capturing ====
   −
    As well as grouping, parentheses serve a second purpose. They can be used to capture the results of parts of the regexp match for later use. The results end up in $1 , $2 and so on.
+
As well as grouping, parentheses serve a second purpose. They can be used to capture the results of parts of the regexp match for later use. The results end up in '''$1''' , '''$2''' and so on.
    
         # a cheap and nasty way to break an email address up into parts
 
         # a cheap and nasty way to break an email address up into parts
Line 459: Line 459:  
==== Other regexp features ====
 
==== Other regexp features ====
   −
    Perl regexps also support backreferences, lookaheads, and all kinds of other complex details. Read all about them in perlrequick, perlretut, and perlre.
+
Perl regexps also support backreferences, lookaheads, and all kinds of other complex details. Read all about them in [http://perldoc.perl.org/perlrequick.html perlrequick], [http://perldoc.perl.org/perlretut.html perlretut], and [http://perldoc.perl.org/perlre.html perlre].
    
=== Writing subroutines ===
 
=== Writing subroutines ===

Navigation menu