Link Details

Link 47109 thumbnail
User 221988 avatar

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.
  • 17
  • 0
  • 1584
  • 491

Comments

Add your comment
User 181930 avatar

jwenting replied ago:

0 votes Vote down Vote up Reply

"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.

User 201716 avatar

unchqua replied ago:

0 votes Vote down Vote up Reply

Are you ready for 426 characters long regular expression describing official RFC-822 email address format? http://www.regular-expressions.info/email.html .

User 250139 avatar

matt_yucha@yahoo.com replied ago:

0 votes Vote down Vote up Reply

Optimization - Compile the patterns that will never change in a static block

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.