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

RegEx PHP difficulties

  •  08-19-2007, 11:43 PM

    RegEx PHP difficulties

    Hi!
    The given construction checks strings in the following format for a validation process of a user input.

    AB 123 YZZ-4
    CD 123 OP-4 LUA
    EF 321 OP-4

    RegEx: ^(?:AB|CD|EF)\s\d{1,3}(?:(\s[A-Z]{1,4}-?\d{1,3}?\s?[A-Z]{0,4})|-\d{1,2})

    I checked it with the Expresso 3.0 regex software - working fine. When I insert it into my PHP script ( if(ereg('(^(?:AB|CD|EF)\s\d{1,3}(?:(\s[A-Z]{1,4}-?\d{1,3}?\s?[A-Z]{0,4})|-\d{1,2})), $strg)) the following warning message occurs:

     Warning: ereg() [function.ereg]: REG_BADRPT in

    Escaping (\) all characters takes away the warning message but at the same time makes the expression useless. 
    System is Apache Webserver on Debian with PHP 5.2.0  

    Any ideas what PHP is complaning about?

    Thanks,
    Andre
     

     

View Complete Thread