javascript - Need dotnet regex to replace an underscore (_) with 0% -


we have card being scanned in has zzzz_ss16 printed on card , scans zzzz0%ss16. users registering cards wrong number due misprint. card reprint great isn't option.

i have javascript regex should job having trouble translating work dotnet.

s/^(\w{4}).(\w{4})/\10%\1/ 

we need first 4 characters, replace _ 0%, followed last 4 characters.

hope can assist.

in case can use

^(\w{4})_(\w{4})$ 

and replace $10%$2

regex demo

for .net use this

var pattern = "^([a-za-z0-9_]{4})_([a-za-z0-9_]{4})$"; var template = "zzzz_ss16"; var replacewith = "${1}0%$2"; 

ideone demo


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -