I require regular expression to match exactly 3 or 2 characters after decimal point, so that it validates http://www.xyz.com and not xyz.Complete
I require regular expression to match exactly 3 or 2 characters after decimal point,
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think what you want is
\bI can’t think of a case that’s not reasonably covered by using the word-boundary assertion
\bany of the other answers need only have\bat the end (if it’s always.com, then you’d use.com\bwhich means essentially a literal dot (.) character followed bycom, where whatever follows is something other than a letter, number or underscore. It’s a zero-width assertion, which means it will not capture anything. To allow a.netor.eduas well, you would use\.(com|edu|net)\bThe
\bassertion is supported in most tools and languages using regexes, but if you need to get more precise (for instance, you might want to allow an underscore aftercom), your tool or language compiler may support “lookaheads” which are also zero-width assertions. (in the instance mentioned just above, you would use something like\.(com|net|edu|org|mil|museum)(?![a-zA-Z0-9])which would prohibit numbers and uppercase or lowercase letters)