-Regular expressions is used to perform powerful and efficient text processing
-It is simple like search editors and powerful text processing language
-This is powerful pattern language
-Matching performed based on the bit pattern used for the encoding the character not based graphic representation.
[ ] represent the character class in regex. Find some of the examples below
[PQR]-Matches either an P,Q or R character
Ex: P QQ RRR
[^PQR]-Matches any character except either an P,Q or R.
Ex: EVERYTHING
[P-Z]- Matches characters between P and Z, including P and Z.
Ex: PRIRIOTY
[^P-Z]-Matches characters except P to Z range.
Ex:PRIRIOTY
[P-Z p-z]-Matches characters between P-Z and p-z. 
Ex:PQR3434pqr
\A -  Matches the starting of the line. Not effecting the multiline mode.
Ex: \ABob - Bob is good.
\b - Matches position at a word boundary
Ex: \bGumm - Gummadi  shiGumm Gumm
Gumm\b - Gummadi  shiGumm Gumm
\bGumm\b - Gummadi  shiGumm Gumm
\B matches exactly opposite to \b
Ex: \BGumm - Gummadi  shiGumm Gumm
\d - Matches digits. 
Ex:123abc
\D - Matches all except digits. 
Ex:123abc
\s - Matches any space , tab or newline character. 
Ex:I am learning	Regex 
\S - Matches all except space. 
Ex: I am learning	Regex
\w - Matches letter , digit , underscore Equivalent to [a-zA-Z0-9_]. not matching special characters. 
Ex: Shiva will get 10% _len
\W - Matching anything other than letter , digit , underscore. 
Ex: Shiva will get 10% _len
\Z -  Matches the end of the line. Not effecting the multiline mode.
Ex: Shiva\Z
Gummadidal Shiva
Regex classes by Gummadidal Shiva
. - Matches any character except line terminator. 
Ex: Shiva
.. -Matches two - two  letters 
Ex: Shiva 
| - Matches either left side or right side  
Ex: s|g : gummadidala shiva
* - Matches zero or more characters. 
Ex:PQ*- P PQQQ PRR
+ - Matches one or more characters. 
Ex:PQ+ - P PQQQ PRR
{m} -Matches exactly m characters 
Ex: Q{3}- P PQQQ PRR
Q{3,} - P PQQQ PRR QQ QQQQ minimum = 3 , maximum >3 
Q{3,4} - P PQQQ PRR QQ QQQQ QQQQQ  minimum = 3 , maximum = 4 
$ - Matches the end of the line.effecting the multiline mode.
Ex: Shiva$
Gummadidal Shiva
Regex classes by Shiva. Shiva is good teacher
Thanks to Shiva
Regular Expression Options :
 Using Regular expression options changing scope and visibility of the pattern.
Flag       Behavior
i              Case - insensitive matching 
m            (Multiline)Matching pattern text in multiple lines where (^ , $ represent the                             beginning and end of the line) 
s              (Single line)Matching pattern text in single line
n              (ExplicitCapture) Do not capture unnamed groups.
x              (IgnorePatternWhiteSpace) Exclude unescaped white space 
Operators precedence in Regular Expressions 
For Regex interview questions click here
Thanks for visiting this blog. How is the content?. Your comment is great gift to my work. Cheers.
No comments:
Post a Comment