Re: [PHP] need some regex help to strip out // comments but not http:// urls
On 28.05.2013 23:17, Daevid Vincent wrote: I'm adding some minification to our cache.class.php and am running into an edge case that is causing me grief. I want to remove all comments of the // variety, HOWEVER I don't want to remove URLs... You need a negative look behind assertion ( http://www.php.net/manual/en/regexp.reference.assertions.php ). (?!http:)// will match // only if it isn't preceded by http:. Bye, Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Boolean type forced on string assignment inside if statement
Volmar Machado qi.vol...@gmail.com wrote: When the one of the operators were 2, the cases with returns 2 otherwise returns 0 (Or 1 when any operator is 1). And if the operators are 1 and 2, return 0 too. Its curious for me. is the bitwise and operator. You have to look at the binary representation of the numbers to see what is happening: 2 decimal is 0010 binary 1 decimal is 0001 binary 2 1 == 0010 0001 == == 0 In your other examples you had 2 3 == 0010 0011 == 0010 == 2 and 4 3 == 0100 0011 == == 0 Does this help? Bye, Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unexpected behavior of max() function
On 11.12.2012 07:48, Рогулин С.В. wrote: I encountered with unexpected behavior of max() function. When i pass a parameter ['100', '110,453351020813', '9'], this function gives answer '9' var_dump( max(array('100', '110,453351020813', '9')) ); // will output: // string(1) 9 As the output tells you, you are comparing strings and the character '9' is greater than the character '1' (at the beginning of the two other strings). Bye, Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regexp novice
On 2012-05-17 22:37, Jim Giner wrote: Trying to validate an input of a time value in the format hh:mm, wherein I'll accept anything like the following: hmm hhmm h:mm hh:mm in a 12 hour format. My problem is my test is ok'ing an input of 1300. Here is my test: if (0 == preg_match(/([0][1-9]|[1][0-2]|[1-9]):[0-5][0-9]/,$t)) return true; else return false; Can someone help me correct my regexp? /([0][1-9]|[1][0-2]|^[1-9]):[0-5][0-9]/ The third part of your alternate expressions matches 3:00 from the string 13:00 (it ignores the 1 at the beginning). Using ^ avoids this because now only one digit is allowed before the :. Bye, Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php