Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Regular Expressions Tutorial, the Basics (for BEGINNERS)

by brusimm (Pilgrim)
on Jan 22, 2007 at 18:04 UTC ( [id://595955]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # Example 1
    #
    ...
          } else {                                                # or
          print "No match in our string for our pattern.\n";      # As you
    +'ll see...
      }                                                           # end
    
  2. or download this
    while (<>) {
        if (/brus/) {
            print $_;
        }
    }
    
  3. or download this
    # Example 2
    #
    ...
          } else {
          print "No match in our string for our pattern.\n";      # As you
    +'ll see...
      }                                                           # end
    
  4. or download this
    # Example 3
    #
    ...
      if (/brus/) {   # Our pattern of brus
       print "There, brus showed up.\n" ;   # if pattern is found, print i
    +t!
      }                                                                   
    +                    # end
    
  5. or download this
    # example 4
    #
    ...
    if (s/bru*s/brus/) {                                     # fixing it
     print $_ ;                                              # proving we 
    +fixed it.
     }
    
  6. or download this
    # example 5
    #
    ...
    if (/a/) {
     print $_ ;
     }
    
  7. or download this
    # example 6
    #
    print "Hello" . ' ' . "world"; #Same as 'Hello world'
    
  8. or download this
    # example 7
    #
    ...
     print $_ ;
     }
    #
    
  9. or download this
    # example 8
    #
    ...
    if (/[q-zQ-Z]/) {
     print $_ ;
     }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://595955]
Approved by ww
Front-paged by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 12:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found