PDF Ebook Regular Expressions: The Complete Tutorial
A regular expression (regex or regexp for short) is a special text string for describing a search pattern. You can think of regular expressions as wildcards on steroids. You are probably familiar with wildcard notations such as *.txt to find all text files in a file manager. The regex equivalent is «.*\.txt» .
But you can do much more with regular expressions. In a text editor like EditPad Pro or a specialized text processing tool like PowerGREP, you could use the regular expression «\b[A-Z0-9._%-]+@[A-Z0-9.-]+ \.[A-Z]{2,4}\b» to search for an email address. Any email address, to be exact. A very similar regular expression (replace the first \b with ^ and the last one with $) can be used by a programmer to check if the user entered a properly formatted email address. In just one line of code, whether that code is written in Perl, PHP, Java, a .NET language or a multitude of other languages.
Contents
Tutorial
1. Regular Expression Tutorial
2. Literal Characters
3. First Look at How a Regex Engine Works Internally
4. Character Classes or Character Sets
5. The Dot Matches (Almost) Any Character
6. Start of String and End of String Anchors
7. Word Boundaries
8. Alternation with The Vertical Bar or Pipe Symbol
9. Optional Items
10. Repetition with Star and
11. Use Round Brackets for Grouping
12. Named Capturing Groups0
13. Unicode Regular Expressions
14. Regex Matching Modes
15. Atomic Grouping and Possessive Quantifiers
16. Lookahead and Lookbehind Zero-Width Assertions
17. Testing The Same Part of a String for More Than One Requirement
18. Continuing at The End of The Previous Match
19. If-Then-Else Conditionals in Regular Expressions
20. Adding Comments to Regular Expressions
Download
PDF Ebook Regular Expressions: The Complete Tutorial
Posted in :