【发布时间】:2018-05-15 19:44:28
【问题描述】:
c我想要的是删除<abc>标签之间的所有空格并保留<efg>标签之间的空格
<abc>this is between abc</abc><efg>this is between efg</efg>
<efg>this is between efg</efg><abc>this is between abc</abc>
我想要输出:
<abc>thisisbetweenabc</abc><efg>this is between efg</efg>
<efg>this is between efg</efg><abc>thisisbetweenabc</abc>
string = string.replaceAll("<abc> </abc>", ""); 它不适合我
【问题讨论】:
-
无论如何,在正则表达式中你可以使用
(?:^(<abc>)|\G(?!^))(\S+)[ \t]*replace with$1$2 -
发布简单但真实的用例。我们希望避免出现我们将为当前问题提供解决方案的情况,但事实证明这两个标签可以像
<abc>foo bar<efg>a b c</efg> bam</abc>那样相互嵌套,而不是<abc>foobar<efg>abc</efg>bam</abc>你想要<abc>foobar<efg>a b c</efg>bam</abc>,尽管a b c也是里面<abc>.
标签: java android regex whitespace removing-whitespace