Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Comment on

If we wanted to match a single character, our pattern would be /a./. The control character is a '.' after the letter in question.

No! /a./ means match two characters, an 'a' followed by any other character. To match a single lower-case 'a', the pattern is simply /a/ - try it and see:

$_ = 'He lives in Liberia'; print 'with dot: ', $_ if /a./; # No output print 'without dot: ', $_ if /a/; # Outputs 'without dot: He lives in Liberia'

Also, in your last paragraph, you've inverted your square brackets and slashes...


To clarify, the dot (period) is not a 'control character', as you seem to imagine, but a 'wildcard character'. To quote from perlretut (which I highly recommend you read, and include in your list of other sources):


Update2: s/perlreftut/perlretut, sorry!

In reply to Re: RFC - Regular Expressions Tutorial, the Basics (for BEGINNERS) by Not_a_Number
in thread Regular Expressions Tutorial, the Basics (for BEGINNERS) by brusimm

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (7)
    As of 2014-12-26 02:09 GMT
    Find Nodes?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?

      Results (164 votes), past polls