opencombatclan Posted March 1, 2010 Share Posted March 1, 2010 Hello all. I am currently writing a script to automatically convert lyrics. So lets say I got the following lyrics: lalallalalaa lalallalal lalala lalalal lalalalalala lalala lala la lalal la lalalalal la lalalalal lala la lalal la la la lal lalal Now as you can see (by selecting the text) there is a space character in the newline between the 2nd and 3rd verse How can I remove these specific space characters? Quote Link to comment Share on other sites More sharing options...
cags Posted March 1, 2010 Share Posted March 1, 2010 Completely untested theory, but... $output = preg_replace('#(?<=[\r\n]+)[ ]+(?=[\r\n]+)#', '', $input); Quote Link to comment Share on other sites More sharing options...
opencombatclan Posted March 1, 2010 Author Share Posted March 1, 2010 Thnx for the fast reply However, it does not work. Quote Link to comment Share on other sites More sharing options...
cags Posted March 1, 2010 Share Posted March 1, 2010 Ooops, forgot PHP PCRE doesn't allow variable length look behind assertions. Assuming your input is what you've shown this should work... $output = preg_replace('#([\r\n]+)[ ]+(?=[\r\n]+)#', '$1', $input); If that doesn't work, what you showed is probably not the input, make sure there are newline characters not <br> tags. 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.