PHP - Moved: How Do I Match The Spacebar In Regex?
This topic has been moved to PHP Regex.
http://www.phpfreaks.com/forums/index.php?topic=332077.0 Similar TutorialsOne email address per line, thousands of lines. I was hoping to just use a text editor to do the work, but I may have to make a php loop to do it.
here's the regex:
^([a-z0-9-_\.]+@[a-z0-9-_]+\.[a-z]{2,3})$
Tested the RegEx, and it works great. It returns thousands of lines of matched email addresses. Problem is, I only want it to find the lines that don't match. How do you make RegEx return unmatched lines?
Hi, I am adding "active_filter", "passive_filter" classes to links based on regex pattern coming from the URL: Line 46: https://github.com/laanes/product_filtering/blob/master/APF_URL.php The function gets called on line 89 in he https://github.com/laanes/product_filtering/blob/master/boxes/advanced_product_filtering_box.inc.php You can see it in action he http://www.swanseatimber.co.uk/shop/hafele/brand_281.html by clicking on a category on the left, under the heading "Filter Your Results". The clicked category gets a green background because of the added "active_filter" class. When you click again, it will get "passive_filter" class and the products are not filtered any more. The problem: When moving to other pages by using the pagination at the top of the product results, the class doesn't get added. Therefore, you can't remove the filter because function creating the href on line 72 in he https://github.com/laanes/product_filtering/blob/master/APF_URL.php and the function clearing all filters on line 100 in he https://github.com/laanes/product_filtering/blob/master/APF_URL.php both fail. What's interesting - when selecting a filter, moving to the next page, clicking in the browser url bar and hiting enter(hard reload i think?), the problem disappears and you can play with the filters again. I really hope you find a minute to look into it and help me. I have set up a function to validate user input date in yyyy-mm-dd format taking into account the following possibilities:
the length of the month
February 29th when the year is not a leap year
When I run the code, I do not get any feedback whatsoever, when it should.
This is the code below and I would appreciate your thoughts:
if(!function_exists('checkdate')) { function checkdate($date, $checkyear, $currentmonth) { if($checkyear == 0)//if it is not a leap year { // if current month is february if($currentmonth == 2) { if(!preg_match("/^(20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|1[0-9]|2[0-8])$/", $date)) { // set error for date field return ($error = 'Invalid Date!'); } return ($error = 'valid Date!'); } // if current months are april, june, september or november elseif($currentmonth == 4 || $currentmonth == 6 || $currentmonth == 9 || $currentmonth ==11) { if(!preg_match("/^(20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|1[0-9]|2[0-8]|3[0])$/", $date)) { // set error for date field return ($error = 'Invalid Date!'); } return ($error = 'valid Date!'); } else { if(!preg_match("/^(20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-8]|3[01])$/", $date)) { // set error for date field return ($error = 'Invalid Date!'); } return ($error = 'valid Date!'); } } elseif($checkyear == 1)//if it is a leap year { // if current month is february if($currentmonth == 2) { if(!preg_match("/^(20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|1[0-9]|2[0-9])$/", $date)) { // set error for date field return ($error = 'Invalid Date!'); } return ($error = 'valid Date!'); } // if current months are april, june, september or november elseif($currentmonth == 4 || $currentmonth == 6 || $currentmonth == 9 || $currentmonth ==11) { if(!preg_match("/^(20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|1[0-9]|2[0-9]|3[0])$/", $date)) { // set error for date field return ($error = 'Invalid Date!'); } return ($error = 'valid Date!'); } else { if(!preg_match("/^(20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/", $date)) { // set error for date field return ($error = 'Invalid Date!'); } return ($error = 'valid Date!'); } } } $todate = getdate(); $currentmonth = $todate['mon']; $checkyear = date('L'); $date = 2014-02-31; echo checkdate($date, $checkyear, $currentmonth); Edited by terungwa, 26 July 2014 - 02:43 PM. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=331482.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=326775.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=358535.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=344155.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=308051.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=317764.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=356497.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=356424.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=326673.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=332417.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=345772.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=353870.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=347186.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=320857.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=349116.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=307000.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=317758.0 |