Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Regular Expression Question

by Abigail-II (Bishop)
on Dec 09, 2003 at 10:27 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-03-19 04:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found