Skip to content

Latest commit

 

History

History
47 lines (37 loc) · 1.94 KB

File metadata and controls

47 lines (37 loc) · 1.94 KB

Regular Expressions and Wildcard Characters

Where Regular Expressions are Applicable?

  1. In Form Validations / To Build Validation Frameworks

    • To validate mobile numbers, email IDs, employee IDs.
  2. To Develop Pattern Matching Applications

    • Examples: ctrl+f for find, grep for search.
  3. To Develop Translators like Compilers, Assemblers, Interpreters

    Compiler Design:

    • LA → Lexical Analysis / Tokenization / Scanning.
    • SA → Semantic Analysis.
    • SA → Syntax Analysis.
    • ICG → Intermediate Code Generation.
    • CO → Code Optimization.
    • TCG → Target Code Generation.
  4. To Develop Digital Machines

    • Examples: Binary Incrementer, Multiplier, etc.
  5. To Develop Communication Protocols

    • Examples: TCP/IP, UDP.

If we want to represent a group of strings according to a particular pattern, then we should go for regular expressions. By using wildcard characters, we can build regular expressions. A wildcard character can be used as a substitute for a required sequence of characters in the regular expression.

  1. * → Represents zero or more characters.
  2. ? → Represents only one character.
  3. [] → Range of characters.
  4. [abc] → Either 'a', 'b', or 'c'.
  5. [!abc] → Any character except 'a', 'b', and 'c'.
  6. [a-z] → Any lowercase alphabet symbol.
  7. [A-Z] → Any uppercase alphabet symbol.
  8. [a-zA-Z] → Any alphabet symbol.
  9. [0-9] → Any digit from 0 to 9.
  10. [a-zA-Z0-9] → Any alphanumeric character.
  11. [!a-zA-Z0-9] → Any character except alphanumeric (i.e., special symbols).
  12. [[:lower:]] → Any lowercase alphabet symbol.
  13. [[:upper:]] → Any uppercase alphabet symbol.
  14. [[:alpha:]] → Any alphabet symbol.
  15. [[:digit:]] → Any digit from 0 to 9.
  16. [[:alnum:]] → Any alphanumeric character.
  17. [![:digit:]] → Any character except digits.
  18. {} → List of files with comma separators.