![]() |
Stripping whitespace between commas?
Does anyone know how I can make the following pre_replace also strips out whitespace BETWEEN the commas?
Right now it will trim the elements of any whitespace that may come before or after the comma. But, say, I have this: Code:
2 4 , 3 , 1 1 It won't strip out the space between the 2 and the 4, or the 1 and the 1. Code:
$str = trim(preg_replace('|\\s*(?:' . preg_quote($delimiter) . ')\\s*|', $delimiter, $str)); |
PHP Code:
PHP Code:
(not tested) |
I meant how to add that ability to the pre_replace line I posted, so it does that also. I know how to do it by itself.
Also, your second one doesn't work for spaces. This does: PHP Code:
Now, it there any way to get the preg_replace to do that also between the commas? Right now it only works on spaces before and after the commas themselves. |
If you would like pretty much instant answer on this go ask it on stackoverflow. I use it all the time and I always get my problems solved within 15 to 20 minutes if not sooner. Just a suggestion.
|
I was hoping someone here might have an answer, too. ;)
I just asked on there so we will see what happens. Thanks for the tip. |
All times are GMT. The time now is 10:25 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|