Gossamer Forum
Home : General : Perl Programming :

Reg Exp help

Quote Reply
Reg Exp help
Could anyone explain me some basis reg. exp? I need it for some validation routiones! (See Links Cust. forum)

For example will /^[a-zA-Z_\-.\s]+$/ only allow a-z A-Z _- and spaces?

...and will /^[0-9]$/ will allow everything except 0-9?

Many thanks in advance!

Quote Reply
Re: Reg Exp help In reply to
In Reply To:
will /^[a-zA-Z_\-.\s]+$/ only allow a-z A-Z _- and spaces?
Yep. That's what it appears.

In Reply To:
will /^[0-9]$/ will allow everything except 0-9?
No. It will allow one digit and one digit only.

(I just played around with this to check it out. That's the only way I can figure them out.)



JPD
Quote Reply
Re: Reg Exp help In reply to
Run, don't walk, do not pass go -- out to your local super bookstore and pick up a copy of "Mastering Regular Expressions" by Oreilly. It's in the same series as everything else about perl, I can't see my copy in this mess so I can't tell you what color it is -- but I think it's blue.

It's quickly becoming the bible on regex's.



Quote Reply
Re: Reg Exp help In reply to
Thanks, i ordered it today at amazon.co.uk.

But maybe someone kan help me find a nice reg. exp for a field with streetname and number.

Like: "Streetname 1"
Streetname must contain at leist 3 char, at least 1 space, and at least 1 number. dots allowed


/\w{3,}\.\s+\d+/ is not correct, because "Bond St. 3" and "Bond St 3" is false.