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. preg_match_all("/-?([\d]+)?(\.[\d]+)?/", $string, $matches); ^^-delimiters you can use almost any char you like (beware of chars that have special

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. preg_match_all("/-?([\d]+)?(\.[\d]+)?/", $string, $matches); -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://w

Re: [PHP] Optimal Regex?

2005-09-26 Thread David Pollack
Ok, so this is the actual code that I'm using. and the output is this... *Warning*: No ending delimiter '-' found in */home/da3/public_html/preg.php*on line *6* array(0) { } What am I doing wrong? On 9/26/05, Jochem Maas <[EMAIL PROTECTED]> wrote: > > keep it on the list please. > > and you st

Re: [PHP] Optimal Regex?

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

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
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 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

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", $mat

[PHP] Optimal Regex?

2005-09-26 Thread David Pollack
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); This r