I am trying to create a Pattern to Validate Domain Name without "http://www" , but I am unable to do so Completely please someone help me;
"\\.[a-zA-Z][a-zA-Z]"
".*?([^.]+\\.[^.]+)"
I am trying to create a Pattern to Validate Domain Name without "http://www" , but I am unable to do so Completely please someone help me;
"\\.[a-zA-Z][a-zA-Z]"
".*?([^.]+\\.[^.]+)"
Pattern: ^[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)$
Description
Domain names: This regular expression tests the validity of a domain or hostname. It will match any valid domain name that does not contain characters which are invalid in URLs, and which ends in .com, .org, .net, .mil, or .edu. You can add additional valid TLDs by appending the | (pipe) character and the desired TLD to the list in the parens.
Matches
3SquareBand.com | asp.net | army.mil
For more patterns check here
Have you tried patterns from class Patterns ?
That Pattern API is not perfect in my case so I used this Regular Expression.
Pattern p = Pattern.compile("^(http|ftp|https)://|^[a-zA-Z0-9]+\\.[a-zA-Z][a-zA-Z]" );
For Java developers, this pattern works for my problem:
private static final String DOMAIN_START_END_PATTERN_STRING =
"^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,65}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}$";