Regular Expression Glitch!!!

V

Vai2000

Hi All, These are the sample inputs and expected replacement expression. My
Regular expression is glitchy can someone correct?

// Inputs:
#VE*89*9# // Sample 1
#VE*3*90# // Sample 2
#VE*2*9# // Sample 3

//Want to replace with
#VE*1*1#

Regex rx= new Regex("#[V][E][*][1-9]|[0-9][*][1-9]|[0-9]#");
str=rx.Replace(str,"#VE*1*1#");


TIA
 
S

Stefan Simek

How about "#VE\*\d+\*\d+#"?

It's just off the top of my head, so there could be a problem with it, but I
guess it should work...

HTH,
Stefan

Vai2000 said:
Figured it out
Regex rx= new Regex("#[V][E][*][0-9]{1,}[*][0-9]|{1,}#");

Vai2000 said:
Hi All, These are the sample inputs and expected replacement expression. My
Regular expression is glitchy can someone correct?

// Inputs:
#VE*89*9# // Sample 1
#VE*3*90# // Sample 2
#VE*2*9# // Sample 3

//Want to replace with
#VE*1*1#

Regex rx= new Regex("#[V][E][*][1-9]|[0-9][*][1-9]|[0-9]#");
str=rx.Replace(str,"#VE*1*1#");


TIA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top