Regular Expression Glitch!!!

  • Thread starter Thread starter Vai2000
  • Start date Start date
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
 
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
 
Back
Top