Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Posts
    190
    Thanks
    12
    Thanked 2 Times in 2 Posts

    Regular expression help (errors)

    I'm getting this error
    Warning: preg_match [function.preg-match-all]: Unknown modifier '.' in /home3/thephou0/public_html/pelotonpoints/includes/usac-scrape.php on line 24
    I'm just trying to find a date in mm/dd/yyyy

    code looks like this:


    PHP Code:
    **LINE 24** ---> $date_regex ='/(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)[0-9]{2}/';
    $n preg_match($date_regex,$date_grab,$date); 
    $date_grab = "07/26/2009 -BLAH BLAH BLAH"
    Last edited by tspek; 02-04-2010 at 08:45 PM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    You're delimiter is the / character. As soon as it hit it again (ie here: '/(0[1-9]|1[012])[- /), it considers everything else to be outside of the patterns and is expecting modifiers (such as msiU, etc). Correct it by either choosing a new delimiter (other common ones are # and |), or by escaping you're current / with \, so \/ instead.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    tspek (02-04-2010)

  • #3
    Regular Coder
    Join Date
    Oct 2009
    Posts
    190
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Fou-Lu View Post
    You're delimiter is the / character. As soon as it hit it again (ie here: '/(0[1-9]|1[012])[- /), it considers everything else to be outside of the patterns and is expecting modifiers (such as msiU, etc). Correct it by either choosing a new delimiter (other common ones are # and |), or by escaping you're current / with \, so \/ instead.
    Is this a regular expression thing or a PHP thing, because I grabbed this expression from a library of regular expressions.

    And thanks.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    That I couldn't tell you for certain. I would suspect it is a regular expression thing; logically the pattern thinks its complete when you've provided it with an ending delimiter.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #5
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Quote Originally Posted by Fou-Lu View Post
    I would suspect it is a regular expression thing;
    It is.

  • #6
    Regular Coder
    Join Date
    Oct 2009
    Posts
    190
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by MattF View Post
    It is.
    Then I guess that library sucks

  • #7
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Quote Originally Posted by tspek View Post
    Then I guess that library sucks
    Unless the author just had an off moment. It hapens to us all on occasion. If the same type of error is present in several regex, however, then the quality of the guidance would be debatable.

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Quote Originally Posted by MattF View Post
    Unless the author just had an off moment. It hapens to us all on occasion. If the same type of error is present in several regex, however, then the quality of the guidance would be debatable.
    Yeah, if it was in a PHP page (.php, or any plain text), its definitely wrong. If it was on a webpage, it could have been a stripping issue (magic_quotes_runtime can potentially do that to you).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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