如果使用正则表达式连续出现多于1的字符串,如何从字符串中删除单词 [英] How can I remove a word from a string if it occures more than 1 in a row with regex
本文介绍了如果使用正则表达式连续出现多于1的字符串,如何从字符串中删除单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果连续出现多次,我想删除< br>
这个词。示例
I want to remove the word "<br>"
if it occures more than once consecutively. example
word word< br>< br>
变为word word< br>
和word< br>< br>< br>字< br>< br>
变为word< br> word< br>
我想使用替换或替换所有可能的东西以保持简短
I want to use replace or replace all if thats possible to keep it short
推荐答案
我想使用替换或替换所有可能的东西以保持简短
当然,它是可能的:
yourString = yourString.replaceAll("(<br>)+", "<br>");
它基本上意味着替换所有< br>
一次或多次只有< br>
。
It basically means replace all "<br>
one or more times" with just "<br>
".
这篇关于如果使用正则表达式连续出现多于1的字符串,如何从字符串中删除单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文