A string contains just one comma.
The comma must be followed by one space.
I need to eliminate any combination of leading and trailing spaces around that comma only, then add the required space after it.
Please advice how to do it wit RegEx.
ThankYou have a nice weekend.
A question of spaces ...
Moderator: General Moderators
Code: Select all
preg_replace('#\s{0,},\s{0,}#', ', ', $string);- stereofrog
- Forum Contributor
- Posts: 386
- Joined: Mon Dec 04, 2006 6:10 am
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Yeah, that's a good way to teach. You know, assuming they know how the {} quantifier works. If they do, then giving both examples would clear up any misconception they have about the asterisk, considering it's so overused.astions wrote:I like to be verbose.
Edit: I didn't mean overused in the sense of being used too much. It *is* a necessity.