I want to replace all sequential commas ,, with {"v":""}
for e开发者_C百科xample ,,,,, would also be replaced.
I've tried
preg_replace('/,+/',',{"v":""},', $string);
Though I probably got something wrong. Any help would be appreciated. Thank you.
This should do what you want:
preg_replace('/,{2,}/', ', {"v":""}', $string);
However, a simple regular expression isn't the best tool for this job because it will break as soon as there is a string containing multiple commas.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论