Wednesday, 28 November 2012

Regular Expressions Concept In PHP Part 1


What is regular expression ?

Regular expression originating from the Unix system . where a program was designed , called grep. To help the developers to work on string and manipulate the strings.

Regular expression is search for a pattern in a given string or text. these search pattern written using a special format which a regular expression parser understand.

Regular expression is a very useful tool for developers, they allow to find , identify or replace text, word or any kind of character.

Regular expression is also called REGEX or REGEXP.

Regular expression syntax

Regular Expression                 Will match
1)     Foo                               this is a string, the string “foo”
2)      ^foo                             “foo”  at the start of a string
3)      Foo$                             “foo” at he end of a string  
4)      ^foo$                           “foo” when it is alone on a string
5)      [abc]                              a,b, or c
6)      [a-z]                               any lower case leter
7)      [^A-Z]                           any character that is not uppercase letter
8)      (gif|jpeg)                        matches either gif or jpeg  
9)      [a-z]+                            one or more lowercase letters        
10)   [0-9.-]                           any numbers, dot or minus sign      
11)   ^[a-zA-Z0-9_]{1,}$       any word of at least 1 letter, number or underscore
12)    ([wx])([yz])                  wy, wz, xy, or xz    
13)   [^a-zA-Z0-9]                any symbols but not any letter or number  
14)   ([A-Z]{3}|[0-9]{4})       Matches three letters or four numbers
a
    Dont Forget to leave Your comments...
 
    Part 2 will coming soon.....


0 comments:

Post a Comment