Where Are Javascript's Regular Expressions (regex) Used?
Are they useful to know? How are they used?
Solution 1:
Regular expressions are not a JavaScript-specific feature and are typically used to check for faults in use input, for example to notify users who forget the @ or domain part of an email address or too few/many digits in a phone number. For more examples, look over there.
Solution 2:
Solution 3:
JavaScript is like Perl, has native regular expression notation. Regular expressions are used to match texts. For example, validating age:
if (field.value.match(/^\s*\d+\s*$/) === null) alert("error: invalid age.");
Read this for a documentation: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp
and JS form validation tutorial: http://www.devarticles.com/c/a/JavaScript/Form-Validation-with-JavaScript-Regular-Expressions-Part-1/
Post a Comment for "Where Are Javascript's Regular Expressions (regex) Used?"