Home > DeveloperSection > Interviews > What the mean of different symbols like ^, $, * , + , ?, ., {},[] in Regular Expressions

Posted on    June-08-2013 8:20 AM

 ASP.Net ASP.Net 
 1 Answer(s)
  1163  View(s)
Rate this:

Andrew Deniel
Andrew Deniel

Total Post:5

Posted on    June-08-2013 12:00 AM

These symbols ^, $, * , + , ?, ., {},[] are very usefull like

"^PCDS": Symbols ^ use to matches any string that starts with "PCDS" this can match "PCDS is an Infotech";
"pcds$": Matches a string that ends in the substring "pcds" like "This is pcds";
"^pcds$": Matches a string that starts and ends with "pcds" that could only be "pcds" itself

"ab*": matches a string that has an a followed by zero or more b's ("a", "ab", "abbb", etc.);
"ab+": same as *, but there's at least one b ("ab", "abbb", etc.);
"ab?": there might be a b or not;
"ab.": . matches any character like abd, abh, abt etc;
"ab{2}": matches a string that has an a followed 
by exactly two b's ("abb");
"ab{2,}": there are at least two b's ("abb", "abbbb", etc.);
"ab{3,5}": from three to five b's ("abbb", "abbbb", or "abbbbb").
"[a-z]": matches any char from a to z.

Don't want to miss updates? Please click the below button!

Follow MindStick