regex conditional question

J

Jonathan Driller

Hi,
I am re-writing a PERL script to include form validation. I want to
check if a field has no vowels and only no or 1 letter.

If I check for /[^a|e|i|o|u]/i then "ff" matches (any non-vowel)....
Also, /\w{1}/i matches "fr" - but I want to match only if there is
ONLY one of any letter (any 2+ letter word)...

Also, is there an 'and' like there is an 'or' (eg. '|').

Any help appreciated...

JD
 
J

John W. Krahn

Jonathan said:
I am re-writing a PERL script to include form validation. I want to
check if a field has no vowels and only no or 1 letter.

if ( $field =~ /^[^[:^alpha:]aeiou]?$/i ) {


John
 
T

Tad McClellan

Jonathan Driller said:
I am re-writing a PERL script to include form validation. I want to
check if a field has no vowels and only no or 1 letter.


print "$_ is invalid\n" if /[aeiou]/i or tr/a-zA-Z/ > 1;

If I check for /[^a|e|i|o|u]/i then "ff" matches (any non-vowel)....


That does not do what you think it does.

You should read up on what a character class does.

It is exactly equivalent to /[^uoa|ie]/i for instance...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top