newbtophp Posted November 24, 2009 Share Posted November 24, 2009 How would i preg_replace the space between characters only? For example - before: h e y p h p would turn into: hey php Quote Link to comment https://forums.phpfreaks.com/topic/182812-preg_replace-space/ Share on other sites More sharing options...
cags Posted November 24, 2009 Share Posted November 24, 2009 Speaking for myself I believe that would be impossible. How is the preg engine supposed to know that hey and php are seperate words. Matching a space is simple enough. You could possibly replace all instances of only single spaces using look ahead/behind to ensure it is only a single space if thats what your after. If that's not what your looking for I think you'll have to be more specific. Quote Link to comment https://forums.phpfreaks.com/topic/182812-preg_replace-space/#findComment-964891 Share on other sites More sharing options...
salathe Posted November 24, 2009 Share Posted November 24, 2009 You could possibly replace all instances of only single spaces using look ahead/behind to ensure it is only a single space if thats what your after. That sounds like a good start, given the information presented. Quote Link to comment https://forums.phpfreaks.com/topic/182812-preg_replace-space/#findComment-964945 Share on other sites More sharing options...
newbtophp Posted November 24, 2009 Author Share Posted November 24, 2009 You could possibly replace all instances of only single spaces using look ahead/behind to ensure it is only a single space if thats what your after. Yeps thats what i was trying to do, - solved it. Quote Link to comment https://forums.phpfreaks.com/topic/182812-preg_replace-space/#findComment-965084 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.