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

Re: regex: only want [a-zA-Z] and comma chars in a string

by davido (Archbishop)
on Oct 12, 2003 at 17:34 UTC ( #298675=note: print w/replies, xml ) Need Help??


in reply to regex: only want [a-zA-Z] and comma chars in a string

You're close.
unless ( $tax_collection =~ /^[a-zA-Z]+(?:,[a-zA-Z]+)*?$/ ) { print "<font color=\"#ff0000\"><i>Incorrect format</i></font>"; $errors++; }

What that does is it says match [a-zA-Z] as many times as possible (the first word) followed by a sequence that can be repeated as many times as necessary (or no times). That sequence may start with a comma, and finish with as many [a-zA-Z] characters as possible. The match is anchored from the front of the string to the end (assuming a single-line string).


Dave


"If I had my life to do over again, I'd be a plumber." -- Albert Einstein

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://298675]
help
Chatterbox?
[choroba]: This usually happens when you have more than one version of Perl, and you mix the libraries
[hippo]: Which O/S?
[vedagiri89]: i have searched many forum...not getting resolutions
[vedagiri89]: centos
[Corion]: vedagiri89: Either what choroba said, or maybe you misspelled some module name (on Windows), like use Strict; or something like that.
[vedagiri89]: @choroba, what to do for that
[Corion]: Ah, you are not on Windows, so disregard my opinion.
[vedagiri89]: in centos, how to fix this.
[choroba]: You have to find out why it happened. Was there an OS update?
[vedagiri89]: that is what i can't getting solution

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (13)
As of 2018-06-19 11:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (113 votes). Check out past polls.

    Notices?