Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Reg Ex exercise

by choroba (Chancellor)
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();
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007323]
help
Chatterbox?
[erix]: ah, thanks Discipulus
[1nickt]: erix perhaps you could kindly point out your technique to roho and everyone will be happy.
[Discipulus]: but i'm also animalist, so i' hirted by 1nickt's sig: The way forward always starts with a mammal test... grin..
[erix]: I might if I did remember. It's probably somewhere in the site docs
[uhClem]: I don't favor that sort of thing around here but the place for our politics is wherever we live.
[uhClem]: And besides, the objection to it was off-topic.
[Discipulus]: 1nickt hide signature is a positive action; i think is not a solution here
[erix]: my objection to sigs is just that they take screen space. ( Some monks would have *several* slogans underneath a 1-liner reply )

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2017-06-22 12:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (519 votes). Check out past polls.