grissom Posted January 19, 2012 Share Posted January 19, 2012 Hi folks, I'd be very grateful if you could help as regex is not my forte. I'm looking for something to strip any punctuation characters from the start of a string but retain any punctuation characters thereafter. For example &!%^:Hello World : it's a nice day ! would return Hello World : it's a nice day ! Many thanks ! Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted January 19, 2012 Share Posted January 19, 2012 $output = preg_replace('~^[^\da-z]+~i', '', $input); That will replace any characters at the start of a string up until the first letter or number only Quote Link to comment Share on other sites More sharing options...
grissom Posted January 19, 2012 Author Share Posted January 19, 2012 THANKS JAY That worked like a charm ! I can really admire someone who can sort out regex, whenever I try it's like doing a Rubik's cube in the dark. Thanks again. Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted January 19, 2012 Share Posted January 19, 2012 haha I know that feeling Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.