正则表达式删除 -

问题描述 投票:-2回答:1

嗨我是新的正则表达式。只想知道如何删除文档中特定标记中的“ - ”。我只想删除<TN>标签中的' - '。谢谢!

<BusinessLine> <TN>905-694-9734</TN> <Type>buslinetype-HG</Type> <Status>InService</Status> </BusinessLine>
regex replaceregexp
1个回答
3
投票

你可以使用这个正则表达式:

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

对于Java:

your_string= your_string.replaceAll("(?sim)(?<=<TN>.*?)\\-(?=.*?</TN>)", "");
© www.soinside.com 2019 - 2024. All rights reserved.