Re: [PHP] Optimal Regex?

2005-09-27 Thread Jochem Maas
Jasper Bryant-Greene wrote: David Pollack wrote: Ok, so this is the actual code that I'm using. ? $string = ( 334, -53.44) ( 111 , 222 ); $testStr = $string; // $string = str_replace( , , $string); preg_match_all(-?([\d]+)?(\.[\d]+)?,$string, $matches);

RE: [PHP] Optimal Regex?

2005-09-26 Thread Murray @ PlanetThoughtful
I need to catch all instances of a coordinate in a give string. So far I have this, which only works if the coordinate is in a certain format. $string = (334,-53.44),(111,222); $expression = '([(][-]?[0-9]*[.0-9]*?,[-]?[0-9]*[.0-9]*?[)])'; preg_match_all($expression, $string, $matches);

Re: [PHP] Optimal Regex?

2005-09-26 Thread David Pollack
Wow, that definitely works. I would sort of like to know how to tweak the regex, but maybe this is the best way of doing it. Is [0-9]*[.0-9]*? the best way of looking for a number with decimals? On 9/26/05, Murray @ PlanetThoughtful [EMAIL PROTECTED] wrote: I need to catch all instances of a

Re: [PHP] Optimal Regex?

2005-09-26 Thread Jochem Maas
David Pollack wrote: I need to catch all instances of a coordinate in a give string. So far I have this, which only works if the coordinate is in a certain format. $string = (334,-53.44),(111,222); $expression = '([(][-]?[0-9]*[.0-9]*?,[-]?[0-9]*[.0-9]*?[)])'; here's a horrid little bit of

RE: [PHP] Optimal Regex?

2005-09-26 Thread Murray @ PlanetThoughtful
Wow, that definitely works. I would sort of like to know how to tweak the regex, but maybe this is the best way of doing it. Is [0-9]*[.0-9]*? the best way of looking for a number with decimals? Hi David, Just to answer this question, I would probably use something like the following pattern

Re: [PHP] Optimal Regex?

2005-09-26 Thread Jochem Maas
keep it on the list please. and you still didn't answer the question :-) snip preg_match_all($expression, $string, $matches); ^-- why ? ... are you wrapping the variable in double quotes? /snip ...and also from your code: $string =

Re: [PHP] Optimal Regex?

2005-09-26 Thread David Pollack
Ok, so this is the actual code that I'm using. ? $string = ( 334, -53.44) ( 111 , 222 ); $testStr = $string; // $string = str_replace( , , $string); preg_match_all(-?([\d]+)?(\.[\d]+)?,$string, $matches); var_dump($matches); ? and the output is this... *Warning*: No ending delimiter '-'

Re: [PHP] Optimal Regex?

2005-09-26 Thread Jasper Bryant-Greene
David Pollack wrote: Ok, so this is the actual code that I'm using. ? $string = ( 334, -53.44) ( 111 , 222 ); $testStr = $string; // $string = str_replace( , , $string); preg_match_all(-?([\d]+)?(\.[\d]+)?,$string, $matches); preg_match_all(/-?([\d]+)?(\.[\d]+)?/, $string, $matches); --