Regex help required

前端 未结 3 1238
天命终不由人
天命终不由人 2021-01-24 02:38

I am trying to replace two or more occurences of
(like


) tags together with two

3条回答
  •  一整个雨季
    2021-01-24 03:05

    You can do that changing a little your regex:

    Pattern brTagPattern = Pattern.compile("<\\s*br\\s*/\\s*>\\s*<\\s*br\\s*/\\s*>", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
    

    This will ignore every spaces between two
    . If you just want exactly 2 or three, you can use:

    Pattern brTagPattern = Pattern.compile("<\\s*br\\s*/\\s*>(\\s){2,3}<\\s*br\\s*/\\s*>", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
    

提交回复
热议问题