Chaitanya Lakshmi
  • About Me
  • Job Duties
  • Knowledge Blog
  • Applications
  • Contact Us
    • Linked In
    • Facebook
  • About Me
  • Job Duties
  • Knowledge Blog
  • Applications
  • Contact Us
    • Linked In
    • Facebook

Regular Expression Characterization?

2/24/2012

0 Comments

 
  1. a dollar sign ($) is used to match strings that end with the given pattern.
  2. a caret (^) character at the beginning of a regular expression indicates that it must match the beginning of the string.

  1. The dot (.) metacharacter matches any single character except newline (\).
  2. The vertical pipe (|) metacharacter is used for alternatives in a regular expression.

The metacharacters +, * and ? affect the number of times a pattern should be matched.

  1. '+' means Match one or more of the preceding expression
  2. '*' means Match zero or more of the preceding expression
  3. '?' means Match zero or one of the preceding expression

Curly braces {} can be used differently

  1. With a single integer, {n} means match exactly n occurrences of the preceding expression
  2. With one integer and a comma, {n,} means match n or more occurrences of the preceding expression
  3. With two comma-separated integers {n,m} means match the previous character if it occurs at least n times, but no more than m times

Regular Express with Respective Matches

  1. foo -------> Matches three letters or four numbersThe string "foo"
  2. ^foo -------> "foo" at the start of a string
  3. foo$ -------> "foo" at the end of a string
  4. ^foo$ -------> "foo" when it is alone on a string
  5. [abc] -------> a, b, or c
  6. [a-z] -------> Any lowercase letter
  7. [^A-Z] -------> Any character that is not a uppercase letter
  8. (gif|jpg) -------> Matches either "gif" or "jpeg"
  9. [a-z]+ -------> One or more lowercase letters
  10. [0-9\.\-] -------> Аny number, dot, or minus sign
  11. ^[a-zA-Z0-9_]{1,}$ -------> Any word of at least one letter, number or _
  12. ([wx])([yz]) -------> wy, wz, xy, or xz
  13. [^A-Za-z0-9] -------> Any symbol (not a number or a letter)
  14. ([A-Z]{3}|[0-9]{4}) -------> Matches three letters or four numbers
0 Comments



Leave a Reply.

    Archives

    April 2012
    March 2012
    February 2012

    Categor

    All
    Ajax
    Api
    Cross Site Scripting
    Css
    Curl
    Design Patterns
    Drupal
    Exception Handling
    Htaccess
    Html
    Javascript
    Jquery
    Json
    Linux
    Mysql
    Oops
    Php
    Regular Expressions
    Web 2.0
    Webservices
    Wordpress
    Xhtml

    RSS Feed

Powered by Create your own unique website with customizable templates.