Deer Park

Deer Park

  • NA
  • 39
  • 0

Complicated Regular expression scenario.

Sep 20 2012 10:50 AM
So, I have a input string which has html styles data. The end goal is to locate the tag - "#TAG#0.00-0##0#[ ]". There could be multiple of these tags on the input string. 

Once these tags are located, it needs to be replaced with static text with little tweak.

So, if the input string is - 


"This is sample string #TAG#0.00-0##0#[ ] (a) this is another sample string. This is third sample string #TAG#0.00-0##0#[ This is a text] Another sample string."



The output string should look like - 

"This is sample string <tag id = "#TAG#0.00-0##0#">[ ] </tag>  (a) this is another sample string. This is third sample string <tag id = "#TAG#0.00-0##0#">[ This is a text] Another sample string "

How can this be done using regular expression or any other mechanism. Any hint would be highly appreciated. 

Answers (2)