-2

Hi im new to regular expression. Just want to know how to remove '-' in specific tag in document. I only want to remove the '-' in <TN> tag. Thanks!

<BusinessLine> <TN>905-694-9734</TN> <Type>buslinetype-HG</Type> <Status>InService</Status> </BusinessLine>
Toto
  • 89,455
  • 62
  • 89
  • 125

1 Answers1

3

You can use this regex:

(?<=<TN>.*?)\-(?=.*?</TN>)

For Java:

your_string= your_string.replaceAll("(?sim)(?<=<TN>.*?)\\-(?=.*?</TN>)", "");
karthik selvaraj
  • 426
  • 5
  • 12