|
Answer» Below are the basic topics and tips for Regex with examples (1)^The- Its matches and string that starts with the Example:- The crackyourinterview sites has regex values
(2)End$- Its matches a string that ends with world End Example:- this is now end
(3)^The End$-Its matches a string that start with "The" and end with "End" Example:- The data in crackyourinterview has End
(4)data- Its matches the world given Example:- Crackyourinterview have data in it
Quantifiers? ?* + ? and {}
(5)abc*- Its matches string that has ab followed by zero or more c Example:- ab,abc,abcc,abccc
(6)abc+- Its matches string that has ab followed by 1 or more c Example:- abc,abcc,abcc
(7)abc?- Its matches string that has ab followed by zero or one c Example:- ab,abc
(8)abc{2}- Its matches string that has ab followed by two c Example:-abcc
(9)abc{2,}- Its matches string that has ab followed by two or more c Example:-abcc,abccc
(10)abc{2,5}- Its matches string that has ab followed by two upto 5 c Example:-abcc,abccc,abccccc
(11)a(bc)*- Its matches string that has followed by zero or more COPIES of sequence bc Example:-abcbc,abcbcbc
(12)a(bc){2,5}- Its matches string that has followed by zero or more copies of sequence bc from 2 to 5 times Example:-abcbc,abcbcbc,abcbcbcbc
OR operator? ?| or []
(13)a(b|c)- Its matches string that has followed by b or c Example:- ab,ac
(14)a[bc]- Its matches string that has followed by b or c Example:- ab,ac
Character CLASSES? ? d w s and .
(15) d- Its matches a single character that is a digit Example:- one1data,keepit1data,key2234
(16) w- Its matches alphanumeric character plus underscore Example:-crack_yourinterview
(17) s- Its matches whitespace character(includes tabs and line breaks) Example:- , ,
(18). - Its matches any character Example:- a,cd,csd,fdf
d, w and s also present their negations with D, W and S respectively
|