
January 11th, 2013, 09:21 AM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 2
Time spent in forums: 1 h 9 m 40 sec
Reputation Power: 0
|
|
|
Regex matching characters unless they're at the end of a string
Not sure how to explain this, but here it goes.
could contain a string followed by none, one or multiple dots:
Code:
test
test.
test..
test...
etc
Using regex I'm looking for any invalid characters in $val and then I want to replace them.
Code:
(preg_replace('-['.$inv.']-',"",$val))
$inv is an array of invalid entries, this also includes a dot.
How do I strip all $inv characters from $val EXCEPT any dots on the end? eg:
if $val = te%st... the correct result should be test…
if $val = te.est. the correct result should be test.
Hope that makes sense. Thanks.
|