Tuesday, November 23, 2010

Regular Expressions

Regular Expression of Email:
string :rahul@gmail.com
exp.:([a-z])+@([a-z])+\.([a-z])+([a-z])

Passwords cannot contain sequences of 3 or more of the same character
(.)\1\1

  • # the following expression finds double characters
    (.)\1

Brackets, Ranges and Negation[],- ^

Positioning (or Anchors)^,$,.


  • The ^ (circumflex or caret) outside square brackets means look only at the beginning of the target string, for example,
  • The $ (dollar) means look only at the end of the target string, for example, fox$ will
  • The . (period) means any character(s) in this position,

Iteration MetaCharcters ?,* ,+,{n},{}
  • The ? (question mark) matches the preceding character 0 or 1 times only
  • The * (asterisk or star) matches the preceding character 0 or more times
  • The + (plus) matches the previous character 1 or more times,
  • {n} Matches the preceding character n times exactly
  • {n,m} Matches the preceding character at least n times but not more than m times,

More metacharacters()|


Submatches, Groups and Backreferences


for testing and article Please follow
http://www.zytrax.com/tech/web/regex.htm

No comments:

Post a Comment