0%

Regular Expressions

Regular Expressions

Basic Rules

  • \d match one number
  • \w match one letter or one number
  • \s match one space (also include tab)
  • . match any symbol
  • * match any number of symbols (include zero)
  • + match at least one symbol
  • ? match one or none symbol
  • {n} means n symbols
  • {n,m} means n to m symbols

Advanced Rules

  • [] can be used to indicate range
    • [0-9a-zA-Z\_] matches one number or letter or underscore
    • [0-9a-zA-Z\_]+ matches one string containing at least one number, letter or underscore.
    • [a-zA-Z\_][0-9a-zA-Z\_]* matches any string starting with letter or underscore followed by any number of number/letter/underscore
    • [a-zA-Z\_][0-9a-zA-Z\_]{0,19} specify the length of the string
  • A|B match A or B
  • ^ means the header
  • $ means the end
Thanks for Your Supports.