www.webdeveloper.com
Results 1 to 2 of 2

Thread: :confused: How to write Expression ?

  1. #1
    Join Date
    Mar 2011
    Posts
    22

    Question :confused: How to write Expression ?

    How to write regular expression to check weather a word has at least 2 capital letters, 2 numbers, is greater than 8 chars and ends with either the letters 'abc' or 'def'

    no programming need just an expression. Thanks

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,276
    If i am not mistaken, it should answer the question
    PHP Code:
     // 2 capital letters, 2 numbers, is greater than 8 chars and ends with either the letters 'abc' or 'def'
     
    $tst=explode(",","a1bAy7uBdef,a1uiBabc,AB45abc,ABC456def,AyuBhu56deg,hkjERabd,hkjER37Abc");
     foreach (
    $tst as $v) {
         echo 
    "<br><b>$v</b>";
         if (
    preg_match("`(?=(?:[^A-Z]*[A-Z]){2})(?=(?:\D*\d){2})(?=(?:.){5,}(abc|def)$)`",$v)) echo " ok !";
        else echo 
    " no pasaran !"
     } 
    Last edited by 007Julien; 11-25-2011 at 07:23 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles