正则一例:给字符加单引号

有字符串 :a,b,c,d 替换成  'a','b','c','d'

 
   

preg_replace("/\w/","'$0'",'a,b,c,d')

javascript版
 
   

"a,b,c,d".replace(/(\w)/g,function($0){
return "'"+$0+"'"
})


猜你喜欢

转载自blog.csdn.net/TottyAndBaty/article/details/83829219