How to remove extra commas and add commas, for example using PHP
User Submitted Data
stack,,,,,,,,,,,,,,overflow
should be displayed.
stack, overflow
$out = preg_replace("/,+/",", ",$in);
preg_replace('/[,]+/', ',', $string); should do it ... although depending on the nature of the input, you may need a more complex expression.
preg_replace('/[,]+/', ',', $string);
$str = preg_replace('/,+/' , ',' , $str);
This will replace each sequence of one or more commas with one comma.
Source: https://habr.com/ru/post/1758828/More articles:Rails best practice for checking if an object exists before displaying an attribute in a layout - ruby | fooobar.comПроблемы с производительностью WPF RichTextBox - .net"ERROR Errno:: EPIPE: сломанная труба" с Culerity - ruby-on-railsIs there something wrong with wrapping whole Smarty patterns in {strip} tags? - htmlPotential leak of object allocated in iphone - iphoneImplementing Telnet Control on a Web Page - javascriptArithmetic overflow error converting expression to int - tsqlCan a Java static timer handle multiple TimerTasks calling cancel ()? - javaWhat should I do if I do not want my site to be indexed by search engines? - htmlData Caching Methods / Tips / AppFabric - c #All Articles