By krishnas
via javabeat.net
Published: Oct 10 2007 / 10:28
Regular Expressions are basically patterns of characters which are used to perform certain useful operations on the given input. The operations include finding particular text, replacing the text with some other text, or validating the given text. For example, we can use Regular Expression to check whether the user input is valid for a field like Email Id or a telephone number.
SaveShareSend
Tags: java, open source
Comments
jwenting replied ago:
"For example, we can use Regular Expression to check whether the user input is valid for a field like Email Id or a telephone number."
And there of course he makes a fatal mistake.
There is no fixed pattern for email addresses or telephone numbers.
At most you can make an approximation if the input is within a specific problem domain or require a specific pattern, but that would only allow a subset of acceptable values.
unchqua replied ago:
Are you ready for 426 characters long regular expression describing official RFC-822 email address format? http://www.regular-expressions.info/email.html .
matt_yucha@yahoo.com replied ago:
Optimization - Compile the patterns that will never change in a static block
Voters For This Link (17)
Voters Against This Link (0)