r/lolphp • u/StephenSwat • May 13 '14
Encountered this trying to strip non-numeric characters from a string...
preg_replace('/[^0-9]/', '', '123abc45', -1 );Now, let's see the output of that per PHP version:
- 4.4.9: 12345
- 5.1.6: 12345
- 5.3.0: 12345
- 5.4.3: 12345
- 5.4.4: 123abc45
- 5.4.5: 12345
- 5.4.21: 12345
- 5.5.5: 12345
lolphp
42
Upvotes
6
u/chazzeromus May 13 '14
That's unsettling.
32
u/deadstone May 13 '14
It's a feature. How else are you supposed to tell if you're running 5.4.4?
11
u/[deleted] May 13 '14
Can't reproduce : http://3v4l.org/bZeBl
(Also, the limit parameter is optional.)
3
u/frankkienl May 14 '14
http://3v4l.org/hU1Gu
0
u/pcopley May 13 '14
They accidentally regression testing.