I am trying to replace two or more occurences of
(like
) tags together with two
Here's some Groovy code to test your Pattern:
import java.util.regex.*
Pattern brTagPattern = Pattern.compile( "(<\\s*br\\s*/\\s*>\\s*){2,}", Pattern.CASE_INSENSITIVE | Pattern.DOTALL )
def testData = [
['', ''],
['
', '
'],
['< br/>
', '
'],
['
', '
'],
['
< br/ >
', '
'],
['
', '
'],
['
', '
'],
['
w
','
w
'],
]
testData.each { inputStr, expected ->
Matcher matcher = brTagPattern.matcher( inputStr )
assert expected == matcher.replaceAll( '
' )
}
And everything seems to pass fine...