Posts

Showing posts from November, 2013

Understanding Regular Expressions

Will discuss about basic regular expression in three stages. Stage 1 Symbol               Explanation ^                        Start of string $                        End of string .                         Any single character +                        One or more character \                         Escape Special characters ?                        Zero or more characters Input exactly match with “abc”  var  A = / ^ abc $ /; Input start with “abc” var  B = / ^ abc/; Input end with “abc” var  C = /abc $ /; Input “abc” and one character allowed Eg. abcx var  D = / ^ abc . $ /; Input  “abc” and more than one character allowed Eg. abcxy var  E = / ^ abc . + $ /; Input exactly match with “abc.def”, cause (.) escaped var  F = / ^ abc \ . def $ /; Passes any characters followed or not by “abc” Eg. abcxyz12.... var  G = / ^ abc . + ? $ / Stage 2 Char                  Group Explanation [abc]                 Should match any single of character [