Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Regular Expression Question

by Abigail-II (Bishop)
on Dec 09, 2003 at 10:27 UTC ( #313389=note: print w/replies, xml ) Need Help??


in reply to Regular Expression Question

#!/usr/bin/perl use strict; use warnings; my $item = qr /(?:[Aa]|\d+(?:-\d+)?)/; my $list = qr /^$item(?:,$item)*$/; while (<DATA>) { chomp; print "$_: ", /$list/ ? "matches\n" : "does not match\n"; } __DATA__ 1 1-3 a 1,4-6,a 1,4-6,,a 1,4-6, ,1,4-6,a 1,4-6,b 1,4-6-8,a 1,4-a,2 1,4-6,4-6,1234-12,a 1: matches 1-3: matches a: matches 1,4-6,a: matches 1,4-6,,a: does not match 1,4-6,: does not match ,1,4-6,a: does not match 1,4-6,b: does not match 1,4-6-8,a: does not match 1,4-a,2: does not match 1,4-6,4-6,1234-12,a: matches
Abigail

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2022-08-11 17:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?