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
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
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
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)
> 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
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 ..
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
> 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
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
9 matches
Mail list logo