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

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -