The proposed solution is not bad, thanks for that. Although I found a small error in the template itself.
For example, something like 49.000.00.01 will be accepted as a valid IPv4 address, and from my understanding it should not be (it just happened to me during some dump processing).
I suggest improving patter in:
"\\b(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|0)" "\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|0)" "\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|0)" "\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|0)\\b";
This should only allow 0.0.0.0 as an all-zero-in, which I suppose will be correct and it will eliminate all .00. 0,000. and etc.
kelanth
source share