c# - Replacing _x with string.empty using Regex.Replace -


i have string "region_2>0" want replace _2 string.empty using regex.

my expression ((_)[^_]*)\w(?=[\s=!><]) in both regulator , expresso gives me _2. however, code(c#):

regex.match(legacyexpression, "((_)[^_]*)\\w(?=[\\s=!><])").value 

gives me "_2>0", causes replace wrong (it returns "region" since removing whole "_2>0" instead of "_2". result want "region>0". shouldn't code , regex programs give same results? , how can work?

(note string not static, in many different forms, rule want replace last _x in string string.empty.

thanks!

i copied code new project:

static void main(string[] args) {     var legacyexpression = "region_2>0";     var rex = regex.match(legacyexpression, "((_)[^_]*)\\w(?=[\\s=!><])").value;     console.writeline(rex);     console.readkey(); } 

the output _2.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -