WHAT THE MEAN OF DIFFERENT SYMBOLS LIKE ^, $, * , + , ?, ., {},[] IN REGULAR EXPRESSIONS

Andrew Deniel

Total Post:5

Points:25
Posted by  Andrew Deniel
 1394  View(s)
Ratings:
Rate this:
  1. Andrew Deniel

    Post:5

    Points:25
    What the mean of different symbols like ^, $, * , , ?, ., {},[] in Regular Expressions

    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!