Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Problem with regex

  • 09-03-2008 3:38pm
    #1
    Registered Users, Registered Users 2 Posts: 7,041 ✭✭✭


    I have this regex (preg_match) but it won't work and I'm not sure why

    [PHP]
    $regex="/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)-([1-9]{1}|[1-2]{1}[0-9]{1}|[3]{1}[0-1]{1})/([1-9]{1}|[1]{1}[0-2]{1})/'20'([0-9]{2})$/";
    if(preg_match($regex, $input)){ //<<Line 560
    [/PHP]

    It should accept strings like Tuesday-5/5/2005 but I get the error

    Warning: preg_match() [function.preg-match]: Unknown modifier '(' in D: path/to/file.php on line 560

    Any Help?


Comments

  • Registered Users, Registered Users 2 Posts: 1,313 ✭✭✭carveone


    Seachmall wrote: »
    I have this regex (preg_match) but it won't work and I'm not sure why

    Humph. Boards.ie smoked my reply - let's try again!

    I believe that the - and / characters after "Sunday)" and before "'20'" respectively should be escaped - ie: "\-" and "\/". Also not sure why you've quoted the '20', probably shouldn't!

    Conor.

    PS: "[1-9]{1}" and "[1-9]" are the same thing except the latter is less cluttered.


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    Check out ReguLazy


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Nice app called RegExBuddy will help you no end with that.


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Regex Builder is free and handy if you're on windows.


Advertisement