Regexp for selecting spaces between digits and decimal char
Posted
by Tirithen
on Stack Overflow
See other posts from Stack Overflow
or by Tirithen
Published on 2010-06-02T19:21:16Z
Indexed on
2010/06/02
19:24 UTC
Read the original article
Hit count: 309
I want to remove spaces from strings where the space is preceeded by a digit or a "." and acceded by a digit or ".". I have strings like: "50 .10", "50 . 10", "50. 10" and I want them all to become "50.10" but with an unknown number of digits on either side. I'm trying with lookahead/lookbehind assertions like this:
$row = str_replace("/(?<=[0-9]+$)\s*[.]\s*(?=[0-9]+$)/", "", $row);
But it does not work...
© Stack Overflow or respective owner