Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Reg Ex exercise

by choroba (Canon)
on Dec 05, 2012 at 16:28 UTC ( #1007323=note: print w/ replies, xml ) Need Help??

in reply to Reg Ex exercise

| stands for "or" only inside a regular expression. Outside, you have to use || or or. The vertical bar alone is a "bitwise or", see perlop. No "or" is needed, though:

#!/usr/bin/perl use warnings; use strict; use Test::More; my $r = qr/^-? # Can start with a minus. (:? # Non capturing group. [0-9]+ # Digits. Does not match Unicode digits as \d + does. (?: # Another group, this one will be optional. \. # The dot. Backslashed to lose its special me +aning. [0-9]+ # Digits again. )? # End of the inner group, the ? makes it opti +onal. ) # End of the outer group. $ # And nothing more. /x; like ($_, $r) for qw/ 4 -7 0.656 -67.35555 /; unlike($_, $r) for qw/ 5. 56F .32 -.04 /; done_testing();
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Comment on Re: Reg Ex exercise
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2015-11-26 11:38 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (697 votes), past polls