Razor Regex Replace All But Numbers and One Dash Between -


i want include number followed 1 dash , number.

@regex.replace(@a, @"[^0-9+-]", "")

... includes dashes.

replace string this:

text (characters!+-) 11-20 text-dashes-after-not counted 

to become just:

11-20 

http://regexr.com/3b0k7

the problem allows number of dashes, , want include 1 if between numbers -- number of spaces between first number, dash, , second number.

you can use regex:

@regex.replace(@a, @"^.*?\b(\d+\s*-\s*\d+)\b.*", "$1") 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -