climbjm Posted August 23, 2006 Share Posted August 23, 2006 I want to take any string of two or more spaces and replace it with one space.[code]$string = " ";$string = ereg_replace("\s\s*"," ",$string);[/code]you get the idea...I have a valid reason for needing this, but it is too long to explain. Link to comment https://forums.phpfreaks.com/topic/18381-solved-replace-regular-expression-for-two-or-more-spaces/ Share on other sites More sharing options...
climbjm Posted August 23, 2006 Author Share Posted August 23, 2006 I found what I was looking for...$string = preg_replace("/(\s){2,}/i"," ",$string); // gets rid of mutliple spaces and replaces it with one in the middle of a string. Link to comment https://forums.phpfreaks.com/topic/18381-solved-replace-regular-expression-for-two-or-more-spaces/#findComment-79032 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.