I want to delete whitespace character between /> and <,
after read this What is a non-capturing group? What does (?:) do?
, I used the pattern like this (?<=\\>)(\\s*\r?\n?)(?=\\<)
. But I found when I used the pattern like this (?<=\\>)(?:\\s*\r?\n?)(?=\\<)
, it can also work well. Here is my test case :
<a>asdfdsf</a> \n <b> hahaha <b/> <a>asdfdsf</a> \n <b> hahaha <b/> <a>asdfdsf</a> \n <b> hahaha <b/>
s.replaceAll("(?<=\\>)(?:\\s*\r?\n?)(?=\\<)", "")
s1.replaceAll("(?<=\\>)(\\s*\r?\n?)(?=\\<)", "")
and I got the result :
<a>asdfdsf</a><b> hahaha <b/><a>asdfdsf</a><b> hahaha <b/><a>asdfdsf</a><b> hahaha <b/>
after used the 2 patterns above.
How does (?:\s*\r?\n?)(?=\<) work? Why they have the same result?