Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Full Name Validation - opening a can of worms ?

Last post 07-11-2006, 10:18 PM by masster. 26 replies.
Page 2 of 2 (27 items)   < Previous 1 2
Sort Posts: Previous Next
  •  07-10-2006, 2:45 AM 19426 in reply to 19425

    Re: Full Name Validation - opening a can of worms ?

    XiCheng, fill my knowledge plz.
    What is the '?' stands for ? Because if i try your expression in Visual regEXP 3.0, it shows an error right at '?'.

    I'm sure your expression is correct, but just to learn exactly, can i use this pattern in PHP as is?
  •  07-10-2006, 12:57 PM 19446 in reply to 19426

    Re: Full Name Validation - opening a can of worms ?

    masster:
    XiCheng, fill my knowledge plz. What is the '?' stands for ? Because if i try your expression in Visual regEXP 3.0, it shows an error right at '?'. I'm sure your expression is correct, but just to learn exactly, can i use this pattern in PHP as is?


    Hi, I dont know which ? you were saying.

    (?: ... ) is non-capturing grouping construct
    \s?   means zero or one whitespace.

    the pattern ^(?:[A-Z0-9'-.]+\s?)+(?<=\S)$ is using Perl-compatible regex syntax. I dont know Visual regEXP 3.0's regexes. If it's DFA regex, maybe you should change (?: ... ) to ( ... ) or \( ... \) to group [A-Z0-9'-.]+ and \s? together.

    This pattern should work fine under PHP where you should use preg_match(...) instead of ereg_match(...).

    Good luck,
    Xicheng

    perl -le 'print"So~*kde~box*DS*Zoxf*fe|er"^$\x23'
  •  07-10-2006, 6:07 PM 19465 in reply to 19446

    Re: Full Name Validation - opening a can of worms ?

    Visual Regexp 3.0

    http://laurent.riesterer.free.fr/regexp/
  •  07-10-2006, 6:32 PM 19467 in reply to 19465

    Re: Full Name Validation - opening a can of worms ?

    masster:
    Visual Regexp 3.0 http://laurent.riesterer.free.fr/regexp/


    oh, I dont have Windows machines right now, but if you can try it on the Linux command line in PHP, like:

    php -r '
        $str = "M T  T";
        if (preg_match("/^(?:[A-Z0-9\47-.]+\s?)+(?<=\S)$/", $str))
            print "Matched : $str\n";'

    and change the value of $str to your test string, and then you can check up the matching result. :-)

    I'll try Visual Regexp this evening at home.

    Xicheng

    perl -le 'print"So~*kde~box*DS*Zoxf*fe|er"^$\x23'
  •  07-10-2006, 6:36 PM 19468 in reply to 19467

    Re: Full Name Validation - opening a can of worms ?

    I found this: http://www.phpbuilder.com/columns/dario19990616.php3?print_mode=1 and also PCRE regex syntax on PHP manual and differences From Perl.
  •  07-10-2006, 6:47 PM 19469 in reply to 19468

    Re: Full Name Validation - opening a can of worms ?

    masster:
    I found this: http://www.phpbuilder.com/columns/dario19990616.php3?print_mode=1 and also PCRE regex syntax on PHP manual and differences From Perl.


    in the above weblink you provided, it's about ereg_match(...) which is using POSIX NFA regex engine and it's different from Perl's traditional NFA(or PCRE). If you use preg_match(...) then it's PCRE which means Perl Compatible Regular Expression.

    why cann't you just try it in your php enviroment with preg_match(...) instead of ereg_match(...)??

    Xicheng

    perl -le 'print"So~*kde~box*DS*Zoxf*fe|er"^$\x23'
  •  07-10-2006, 7:26 PM 19470 in reply to 19469

    Re: Full Name Validation - opening a can of worms ?

    Xicheng Jia:
    why cann't you just try it in your php enviroment with preg_match(...) instead of ereg_match(...)??



    Xicheng
    chill, plz. The answer is simple: I am not a PHP guru, that's why I use CodeCharge Studio for building fairly complex PHP + mySQL applications. CodeCharge Studio is an excellent visual IDE, don't need to write too much code by hand, and inside it I have to enter in a textbox the EXACT regexp I need to use for validation. Hope it's clear now. Sorry if I avoid using preg_match and stuff.
  •  07-10-2006, 8:51 PM 19472 in reply to 19470

    Re: Full Name Validation - opening a can of worms ?

    masster:
    Xicheng Jia:
    why cann't you just try it in your php enviroment with preg_match(...) instead of ereg_match(...)??

    Xicheng
    chill, plz. The answer is simple: I am not a PHP guru, that's why I use CodeCharge Studio for building fairly complex PHP + mySQL applications. CodeCharge Studio is an excellent visual IDE, don't need to write too much code by hand, and inside it I have to enter in a textbox the EXACT regexp I need to use for validation. Hope it's clear now. Sorry if I avoid using preg_match and stuff.

    Well, I just checked your tool, Visual REGEXP 3.0. it does not support look behind construct (?<= ... ) which produced the error of the pattern.. But if you are going to use PHP and preg_match(...), it does support look-behind.

    you can use look-ahead to do the same thing though. try:

        ^(?=.*\S$)(?:[A-Z0-9'-.]+\s?)+$

    in Visual REGEXP 3.0...

    BTW. you need also to uncheck the 'nocase' option

    Good luck,
    Xicheng


    perl -le 'print"So~*kde~box*DS*Zoxf*fe|er"^$\x23'
  •  07-11-2006, 12:49 AM 19474 in reply to 19470

    Re: Full Name Validation - opening a can of worms ?

    Just checked the book "Programming PHP", and there are several main differences of PHP's regexes from Perl's:
    1) (?{ perl code }), (??{ perl code }) constructs are not supported.
    2) \E, \G, \L, \l, \Q, \u, and \U options are not supported.
    3) Parenthesized submatches within negative assertions are not remembered.
    4) Alternation branches within a lookbehind assertion can be of different lengths.

    BTW. there is no ereg_match(...), should be ereg(...).

    Xicheng


    perl -le 'print"So~*kde~box*DS*Zoxf*fe|er"^$\x23'
  •  07-11-2006, 3:11 AM 19478 in reply to 19474

    Re: Full Name Validation - opening a can of worms ?

    Just found this little gem: RegexBuddy, which has a very nice manual and tutorials too. I'm all over it to learn regex.

    btw, for those interested... http://rapidshare.de/files/25518636/regex.rar.html :)
  •  07-11-2006, 10:50 AM 19491 in reply to 19478

    Re: Full Name Validation - opening a can of worms ?

    masster,

    thanks for hte link man - it's a really coo program to have. Have u installed it? does it work?

    Sergei

  •  07-11-2006, 10:18 PM 19509 in reply to 19491

    Re: Full Name Validation - opening a can of worms ?

    Like a charm, Sergei...
Page 2 of 2 (27 items)   < Previous 1 2
View as RSS news feed in XML