Which regular expression correctly matches a valid IPv4 address (e.g., "192.168.1.1") in Java?

Last Updated :
Discuss
Comments

Which regular expression correctly matches a valid IPv4 address (e.g., "192.168.1.1") in Java?

\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}

[0-9]{3}\\.[0-9]{3}\\.[0-9]{3}\\.[0-9]{3}

(\\d+\\.\\d+\\.\\d+\\.\\d+)

\\d{1,3}\\,\\d{1,3}\\,\\d{1,3}\\,\\d{1,3}

Share your thoughts in the comments