HOW WE LIST WHICH CHARACTERS WE DON'T WANT ?HOW TO USE BACKSLASH CHARACTER

Andrew Deniel

Total Post:5

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

    Post:5

    Points:25
    How we list which characters we DON'T want ?How to use backslash character

    We can list which characters we DON'T want so just use a '^' as the first symbol in a bracket expression
    (i.e., "%[^a-zA-Z]%" matches a string with a character that is not a letter between two percent signs).
    "^[a-zA-Z]": a string that starts with a letter;
    "[0-9]%": a string that has a single digit before a percent sign;
    ",[a-zA-Z0-9]$": a string that ends in a comma followed by an alphanumeric character. 

    In order to be taken literally, you must escape the characters "^.[$()|*+?{\" with a backslash ('\'), as they have special meaning. On top of that, you must escape the backslash character itself in PHP3 strings, so, for instance, the regular expression "(\$|¥)[0-9]+" would have the function call: ereg("(\\$|¥)[0-9]+", $str)

Answer

NEWSLETTER

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