in reply to regex: only want [a-zA-Z] and comma chars in a string
----#!/usr/bin/perl -w use strict; my %commas = ( 'notalot' => 1, 'england,rugby' => 1, 'chicken,egg,duck,feet' => 1, ',southampton' => 0, 'bristol,' => 0, 'iran,,canada,france' => 0, ); foreach my $key (keys %commas) { unless (($key =~ /^,|,,|,$/)) { print "PASS"; } else { print "FAIL"; } print ": $key\n"; }
FAIL: bristol, PASS: notalot PASS: england,rugby FAIL: iran,,canada,france PASS: chicken,egg,duck,feet FAIL: ,southampton
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: regex: only want [a-zA-Z] and comma chars in a string
by dragonchild (Archbishop) on Oct 13, 2003 at 23:31 UTC | |
|
Re: Re: regex: only want [a-zA-Z] and comma chars in a string
by nevyn (Monk) on Oct 14, 2003 at 19:39 UTC |