lococobra Posted July 13, 2007 Share Posted July 13, 2007 Okay... another regex problem... Lets say I have the following: <?php $input ='foreach($some as $something) echo "ok";'; ?> I want to remove all whitespace from that string, but... I don't want to remove the whitespace around "as" How would I get from that $input... using preg_replace... to the following output... <?php $output ='foreach($some as $something)echo"ok";'; ?> Quote Link to comment Share on other sites More sharing options...
effigy Posted July 13, 2007 Share Posted July 13, 2007 <pre> <?php echo $input ='foreach($some as $something) echo "ok";'; echo '<br>'; echo preg_replace('/(?<!as)\s+(?!as)/', '', $input); ?> </pre> Quote Link to comment Share on other sites More sharing options...
lococobra Posted July 13, 2007 Author Share Posted July 13, 2007 You rule... how do you know so much about regex? If there's some online guide you learned from... point me in the direction please! Quote Link to comment Share on other sites More sharing options...
effigy Posted July 16, 2007 Share Posted July 16, 2007 Keep practicing and read this. 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.