Regex Ignore Space

java, regex

Solution

You can use this regex to allow white spaced anywhere in an IP address:

^\s*([0-9]{1,3}\s*\.\s*){3}[0-9]{1,3}\s*$

Online Demo: http://regex101.com/r/zZ9kH6

Problem

With a lot of trying I have managed to create the following regex. I want to use this to prevent the spamming of IP's. ``` ([0-9]{1,3}(\.+|\s+)){3}[0-9]{1,3} ``` This will catch all the ips if written correctly for example `8.8.8.8` However it doesn't match `"8. 8. 8. 8"` or `"8 .8 .8 .8"` `\s*` But I don't seem to get it working, could anyone help me, and explain me where I need to place the `\s*` to ignore Spaces in between Regards Jurre

Original source