Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-04-2010, 08:33 PM   PM User | #1
tspek
Regular Coder

 
Join Date: Oct 2009
Posts: 190
Thanks: 12
Thanked 2 Times in 2 Posts
tspek is an unknown quantity at this point
Regular expression help (errors)

I'm getting this error
Quote:
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..
tspek is offline   Reply With Quote
Old 02-04-2010, 08:42 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
tspek (02-04-2010)
Old 02-04-2010, 08:48 PM   PM User | #3
tspek
Regular Coder

 
Join Date: Oct 2009
Posts: 190
Thanks: 12
Thanked 2 Times in 2 Posts
tspek is an unknown quantity at this point
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.
tspek is offline   Reply With Quote
Old 02-04-2010, 08:55 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 02-04-2010, 11:21 PM   PM User | #5
MattF
Senior Coder

 
Join Date: Jul 2009
Location: South Yorkshire, England
Posts: 2,322
Thanks: 6
Thanked 304 Times in 303 Posts
MattF will become famous soon enoughMattF will become famous soon enough
Quote:
Originally Posted by Fou-Lu View Post
I would suspect it is a regular expression thing;
It is.
MattF is offline   Reply With Quote
Old 02-05-2010, 12:06 AM   PM User | #6
tspek
Regular Coder

 
Join Date: Oct 2009
Posts: 190
Thanks: 12
Thanked 2 Times in 2 Posts
tspek is an unknown quantity at this point
Quote:
Originally Posted by MattF View Post
It is.
Then I guess that library sucks
tspek is offline   Reply With Quote
Old 02-05-2010, 12:23 AM   PM User | #7
MattF
Senior Coder

 
Join Date: Jul 2009
Location: South Yorkshire, England
Posts: 2,322
Thanks: 6
Thanked 304 Times in 303 Posts
MattF will become famous soon enoughMattF will become famous soon enough
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.
MattF is offline   Reply With Quote
Old 02-05-2010, 04:34 AM   PM User | #8
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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).
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:53 AM.


Advertisement
Log in to turn off these ads.