Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: exact word match

by samarzone (Pilgrim)
on Dec 22, 2010 at 12:23 UTC ( #878496=note: print w/replies, xml ) Need Help??


in reply to exact word match

Square brackets are for matching individual characters. The regex you wrote will reject (because of ^) any word that has any of 'm', 'a', 's', 't', 'e', 'r', '|' .. and so on.

If you meant a valid database name except the names given in your regex you could have written

if($name =~ /^[a-z0-9_]$/i && $name !~ /^(?:master|model|dbccdb|sybsec +urity|sybsystemdb|sybsystemprocs|tempdb|DBA)$/) { print "allowed\n" } else { print "not allowed\n" }

Update: This can also be written in a single regex using negative look-ahead assertion as follows

if($name =~ /^(?!(master|model|dbccdb|sybsecurity|sybsystemdb|sybsyste +mprocs|tempdb|DBA)$)(^[a-z0-9_]+$)/i) { print "allowed\n" } else { print "not allowed\n" }

-- Regards - Samar

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://878496]
help
Chatterbox?
[stonecolddevin]: also hi Corion
[Corion]: stevieb: Yeah, but I don't follow guitar players enough... I never got Prince and I don't think I could recognize his play style. I can recognize Santana and Nile Rodgers, but that's about it, and not really deep knowledge I think ;)
[stevieb]: Jeff Healey cut of My guitar gently weeps
[stonecolddevin]: you don't recognize Prince. Prince tells you it's him.
[erix]: Alvin Lee (Ten Years After) played a jazzguitar ("Big Red"), a good warm sound
[stonecolddevin]: I think Stevie Ray is one of maybe 2 or 3 people that could take a Hendrix song and make you go "...huh. this is close." https://open. spotify.com/track/ 0UVM9trirBK5s1xBwL oVhZ
[stonecolddevin]: https://open. spotify.com/track/ 0UVM9trirBK5s1xBwL oVhZ rather
[Corion]: Sadly I must go to bed now :-| See y'all!
[erix]: I really loved/love this "Recorded Live" record, 1973 (yes, I'm that old)
[stonecolddevin]: goodnight Corion

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2017-06-22 21:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (531 votes). Check out past polls.