Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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...

Update:

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):

The period '.' matches any character but "\n"

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

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

    No recent polls found