Regular Expressions

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Regular Expressions - Presentation Transcript

    1. In PHP
      • Regular Expressions are used to do pattern matching
      • PHP ,supports two types of pattern matching POSIX and PERL type.
      • Caret(^)at the beginning of regular expression: Indicates string begin searched must start with this pattern.
      • Ex.
      • ^woo will search “woo”,”wood”, “woooo”
      • but not “wow”
    2. Contd..
      • Dollar($)at end of regular expression : Indicates that string being searched must end with this pattern.
      • Ex.
      • bie$ will search “barbie”,”newbie”
      • but not “biebar”
    3. Contd..
      • Questionmark(?) :Indicates that preceding character should appear ZERO or ONE times in pattern/searched string
      • Ex:
      • wo? will search “wd”,”wod” but not “wood”
    4. Contd..
      • Plus(+):Indicates that preceding character should appear ONE or MORE times in pattern.
      • Ex.
      • wo+ will search “wo”,”woo”,”wow” but not “wa”
    5. Contd..
      • Asterisk(*):Indicates that preceding character should appear ZERO or MORE times in pattern.
      • Ex.
      • wo* will search “w”,”wo”,”wood”,”wd”
    6. Contd..
      • {n}:Indicates that preceding character should appear exactly “n” times in pattern.
      • Ex.
      • wo{3} will search “wooo” but not “woooo”
    7. Contd..
      • {n1,n2}:Indicates that preceding character should appear in pattern atleast “n1” times and atmax “n2” times.
      • Ex.
      • wo{2,4}d will search “wood”,”woood”,”woood” but not “wod”
    8. Contd..
      • {n,}:Indicates that preceding character should appear in pattern atleast “n” times but no maximum limit .
      • Ex.
      • wo{2,}d will search “wood”,”woood”
      • but not “wod”
    9. Contd..
      • Dot(.):Indicates any character except newline.
      • Ex.
      • wo.d will search “woad”,”wo9d”,”wo d”
      • but not “wo d”
    10. Contd..
      • Backslash-d(d) : Indicates any digit [0-9]
      • Ex.
      • “ wodd” will search “wo3d”,”wo7d”
      • but not “woad”
    11. Contd..
      • Backslash-D(D): Indicates any character except digit [^0-9]
      • Ex.
      • woDd will search “woad”,”wo@d”
      • but not “wo2d”
    12. Contd..
      • Backslash-w(w):Indicates any character, digit and underscore(_)
      • Ex.
      • “ wowd” will search “wo0d”,”wo_d”,”woud” but not “wo&d”
    13. Contd..
      • Backslash-W(w): Indicates any character except letter, digit and underscore(_)
      • Ex.
      • woWd will search “wo%d”,”wo@d” but not “wood” or “wo8d”
    14. Contd..
      • Backslash-s(s):Indicates any white space i.e. newline , tab , space
      • Ex.
      • “ wosd” will search “wo d”, “wo d” but not “wood”
    15. Contd..
      • Backslash-S(S):Indicates any character except white spaces i.e. space , tab , newline
      • Ex.
      • “ woSd” will search “wo@d”, “wood” but not “wo d”
    16. Contd..
      • Grouping[]:Indicates group of options
      • Ex.
      • wo[aeiou]d will search “woad”, “woed” ,“woud” but not “wobd”
      • wo[aeiou]{2}d will search “woaed”, “wooud”, “woiud” but not “woaeioud”
    17. Contd..
      • Negotiation(^):Indicates not this group of options.
      • Ex.
      • “ wo[^aeiou]d” will search “wobd”, “wo8d” but not “woad”
    18. Contd..
      • Pipe(|):Indicates options for pattern.
      • Ex.
      • woo$ | ^cut will search “cutabcfoo” , “cutwoo” ,“abcwoo”, “cutabc” but not “woocut”
    19. Contd..
      • Backslash(): to escape character.
      • Ex.
      • wo.d will search “wo.d”
      • wo\h will search “woh”
    20. Contd..
      • Parenthesis(()):Indicates sub pattern
      • Ex.
      • w(oo)?d will search “wood” , “wd”
    21. PHP PCRE FUNCTIONS
      • preg_match() : Perform a regular expression match.
      • preg_match_all() : Perform a global regular expression match
      • preg_replace() : Perform a regular expression search and replace
      • preg_split() : Split string by a regular expression
      • preg_grep () : Return array entries that match the pattern
    22. REFERENCE
      • http://in.php.net/manual/
    SlideShare Zeitgeist 2009

    + Anand sharmaAnand sharma Nominate

    custom

    133 views, 0 favs, 0 embeds more stats

    Basic regex tutorial

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 133
      • 133 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 0
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Tags