Gaurang Mehta

Replace the word with actual value in a string using regular expression.

Discussion created by Gaurang Mehta on Feb 18, 2011
Latest reply on Feb 23, 2011 by Tom Sheckells

Hi ;

Can anyone tell me how can I replace a word with actual string using regular expression.

 

Scenario :

strString = "Members NDC Code is  [NDC Code] and Medical Description is [Medical Description] which is high risk".

 

In the above string I want to replace [NDC Code] with actual value  and [Medical Description] with actual message.

 

I was trying like this :

 

regEX  is some RegularExpression initially ("[NDC Code]");

strString = regEX.substitute(strString, 12);

 

regEX1 is some RegularExpression initially ("[Medical Description]");

strString = regEX.substitute(strString, "Drug");

 

I thought this will work, but behaving akwardly, like replacing wherever it finds "e" and

" " with 12.

 

Output required is  :

Members NDC Code is  12 and Medical Description is Drug which is high risk.

 

Thanks in advance. 

Outcomes