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

Re: what means this regex? $x = qr/[0-9a-f]{4|8}/

by reasonablekeith (Deacon)
on Jun 09, 2006 at 08:38 UTC ( #554447=note: print w/replies, xml ) Need Help??


in reply to what means this regex? $x = qr/[0-9a-f]{4|8}/

Regarding
{4|8}
this is a nice idea, but doesn't do anything special. a curly bracket is only a special character when it is found in one of these forms {n}, {n,} or {n,m}.

As your example isn't like this, the bracket is just matched as a plain character. What your first regex shows is just an alternation, equivalent to the following...

if (/[0-9a-f]\{4/ or /8\}/} { print "matched\n"; }
Note that I've escaped the curly bracket just to be explict, it's not actually necessary
---
my name's not Keith, and I'm not reasonable.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://554447]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2021-10-21 15:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (83 votes). Check out past polls.

    Notices?