regex conditional question

Discussion in 'Perl Misc' started by Jonathan Driller, Aug 19, 2003.

  1. 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
     
    Jonathan Driller, Aug 19, 2003
    #1
    1. Advertising

  2. Jonathan Driller wrote:
    >
    > 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
    --
    use Perl;
    program
    fulfillment
     
    John W. Krahn, Aug 19, 2003
    #2
    1. Advertising

  3. Jonathan Driller <> wrote:

    > 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...


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Aug 19, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SmViQnVzaGVsbA==?=

    Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine?

    =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    716
    =?Utf-8?B?SmViQnVzaGVsbA==?=
    Oct 22, 2005
  2. Rick Venter

    perl regex to java regex

    Rick Venter, Oct 29, 2003, in forum: Java
    Replies:
    5
    Views:
    1,639
    Ant...
    Nov 6, 2003
  3. Alec S.
    Replies:
    10
    Views:
    10,194
    Alec S.
    Apr 16, 2005
  4. Martin Evans

    RegEx conditional search and replace

    Martin Evans, Jul 5, 2006, in forum: Python
    Replies:
    6
    Views:
    560
    Blair P. Houghton
    Jul 6, 2006
  5. Replies:
    3
    Views:
    780
    Reedick, Andrew
    Jul 1, 2008
Loading...

Share This Page