Regex for validating domain name
For the first part, I could use regex and validate, but how to ensure that the domain is reachable too.[ August 10, 2005: Message edited by: amus manj ] Amus, you appear to have selected not to receive private messages, so I can't reply to the private message you sent me. You can also Save & Share with the Community, and view patterns you create or favorite in My Patterns. The side bar includes a Cheatsheet, full Reference, and Help. This are the issues that I've found: What if a user enters or These are still easy to detect, but what if the user types a different protocol, like ftp:// or typo's like htp:// or \ ... regexp_id=25 Also, maybe you could put " right before the input box to make it more clear to users that they shouldn't put that in the box.
)$"; Pattern pattern = Pattern.compile(regex); for(String email : emails) [email protected]: true [email protected] : true [email protected]: true [email protected]: true [email protected] : true [email protected] : true [email protected] : true @: false This regex example uses all the characters permitted by RFC 5322, which governs the email message format. :\.[a-z A-Z0-9-] )*$"; Pattern pattern = Pattern.compile(regex); for(String email : emails) Now lets modify the regex such that domain name must include at least one dot, and that the part of the domain name after the last dot can only consist of letters. The top-level domain (in these examples) must consist of two to six letters only. Anywhere you need to deal with patterns, regular expressions are your friend.
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums Is there any java built-in to verify if a domain name is valid.