Symbols used in the Regular Expressions .

The Regular Expression uses the symbols for the string match and filter etc…
Some of them are listed below :

Using ^ and $ Symbols 

Lets us take a look at the 2 special  symbols  ^ and $ . These symbols indicates the starting and ending of the string .

As for Example : 

“^Interview”   : Matches any string starting with the Interview.
“Questions$”   : Matches any string ending with Questions .
“^Interview$” : Matches the that starts and end with Interview.
“Questions”     :  Matches the string that has text Questions in it

The last example indicate that the pattern can match or occur  anywhere in the string. the search pattern are not bounded with any edge i.e either starting or ending .

Using *,+ and ? Symbols 

The Symbols “*” , “+” , “?”  denotes the number of times the pattern/characters appears in the string .

  • “*” means zero or more 
  • “+” means one or more 
  • “?” means zero or one 
These Symbols can be used as :

“pi*”  : Matches the string that has character(s) followed by zero or more  i , i.e the possibilities are “p” , “pi” , “pii” and so one…

“pi+”  : Matches the string that may have character(s) followed by at least or more  i , i.e the possibilities are “pi” , “pii” and so one…
“pi?”  : Matches the string that has character(s) but may or may not followed followed by single character i , i.e the possibilities are “p” , “pi” .

“p?i+$*”
  : Matches the string that may have character(s) but compulsorily ends with at least   one or more  i   i.e the possibilities are “i” , “pi” , “pii” , “piq” and so one…

    Using Bounds {}

    Bounds can also be used , which comes inside the braces and indicates the ranges in the terms of occurrences .

    They are used as :

    “pi{2}”  : Matches the string that may have character(s) followed by exactly two  i  , i.e the possibilities are  “pii” .
    “pi{2,}”  : Matches the string that may have character(s) followed by at least two  i  , i.e the possibilities are  “pii” , “piii” ,  “piiii”  and so on.
    “pi{3,5}”  : Matches the string that may have character(s) but compulsorily ends with at least  three but not more than  five  i   i.e the possibilities are “piii” , “piiii” , “piiiii” and so one…
    Using Quantifiers

    To quantify a sequence of characters , put them inside the round bracket .

    They are used as :

    • “p(iq)*” : Matches the string that has characters followed by zero or more copies of the sequence “iq” .
    • “p(iq){1,5}” : Matches the string that has characters followed at least one but not more than fove copies of the sequence “iq”.
    Using | The OR Operator 
    The symbols “|” works similar to the OR operator that can be used as :

    • “Shah|Mr.Shah” : Matches the string that holds either Shah or Mr.Shah.
    • “(Shah | Shaha) Professor ” : Matches the string that holds either ShahProfessor ornShahaProfessor .
    • “(p|i)*q” : Matches the string that has sequences of characters i.e “pq” ,”ppq” , “pppq” and so on  , “iq”,”iiq” ,”iiiq” and so on .

    Using .The Period

    A Period (‘.’) Stands for any single character and can be used as :
    • “s.[0-9]”  :  Match the string that has a characters followed by any one character further followed by the digit. The Possibilities are “s1” , “s2” and and so on …
    • “^.{5}$”  :  Matches the string exactly with the eight characters , The possibilities are “mango” , “apple” and so on .
    Using [ ] Bracket Expressions 
    • “[pq]” :  Match the string that has either character p or q . It is similar to p|q.
    • “[a-d]” : Match the string that holds the characters through a to d . This is equal to “a|b|c|d” or “[abcd]” .
    • “^[a-zA-Z]” : Matches the string that begins with the letter .
    • “[0-9]%” : Matches the string that has single digit before the percent sign .
    • “,[a-zA-z0-9]$” : Matches the string that ends with comma followed by digits .
    • “%[^a-zA-Z]% : Matches the string with a character that is not an alphabet between the two percent signs .



    Leave a Reply

    Your email address will not be published.Required fields are marked *