[Java] – Regular expression to match IPv4 address

I saw such question on SO. There was no solution with RegEx so… I was bored I think. public static boolean isValid(String ip) { boolean isvalid;   isvalid = ip.matches( "(([0-9]|[0-9]{0,2}|1[0-9]*{0,2}|2[0-5][0-5]|0{0,3}).){3}" + "([0-9]|[0-9]{0,2}|1[0-9]*{0,2}|2[0-5][0-5]|0{0,3})" );   return isvalid; }public static boolean isValid(String ip) { boolean isvalid; isvalid = ip.matches( "(([0-9]|[0-9]{0,2}|1[0-9]*{0,2}|2[0-5][0-5]|0{0,3}).){3}" + "([0-9]|[0-9]{0,2}|1[0-9]*{0,2}|2[0-5][0-5]|0{0,3})" ); return isvalid; }

[Java] regular expression to match emails and domains works with gTLD

Recently we got many new top-level domains like .international, .berlin etc, so older regular expressions are no longer valid. Below you can see a list of valid domains; an address may contain . (dot), – (minus) and .subdomain (domain may contain many sub-domains). A domain must end with a letter, it cannot be . (dot) […]