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

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -