regex - Is there a single regular expression to replace a number in a delimited list? -


i have string can range empty string arbitrary list of comma delimited numbers. example: "1,2,3"

unfortunately write code remove element have bunch of if statements--mainly deal if first, last, or element in list. keep thinking there has got better way!

for example, need able remove element '2' in following lists:

"1,2,3" "1,3,2" "2,1,3" "2" "12,2,21" "" 

this should want:

/(\b|,)2(\b|,)/ 

Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

What's the encoding type of Android 2.2 push message? -

What do you think are the useless tags in HTML? -