Using Regular Expressions

Introduction to using regular expressions


A regular expression describes a pattern of characters. Regular expressions are typically used to verify that a text value conforms to a particular pattern (such as verifying that a user-entered phone number has the proper number of digits) or to replace portions of a text value that matches a particular pattern.

Regular expressions can be simple. For example, suppose you wanted to confirm that a particular string matches "ABC," or wanted to replace every occurrence of "ABC" in a string with some other text. In that case, you could use the following regular expression, which defines the pattern consisting of the letters A, B, and C in sequence:

var pattern:RegExp = /ABC/

Note that the regular expression literal is delineated with the forward slash (/) character.

To test if a string matches the regular expression, use this syntax:

trace(pattern.test("ABC")); // traces true
trace(pattern.test("AbC")); // traces false

Check this link for more. 



Post A Comment

Anti-Spam Quiz: