├── LICENSE
├── README.md
└── examples
├── advanced-sentence-examples.txt
├── date-matching.txt
├── meme-example.txt
├── password_regex_match.txt
├── regex-advanced.txt
├── regex-basics.txt
├── regex-groups.txt
└── regex-sentence-examples.txt
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Keith Galli
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Complete Regular Expressions Tutorial!
2 | Code & text examples for my video tutorials on regular expressions (regex).
3 |
4 | The first part of the video tutorial can be found here: https://youtu.be/vsa9GGzMFXQ
5 |
6 | Some additional practice exercises can be found here: https://youtu.be/Qv_RYpREz5k
7 |
8 | ## Exercises
9 |
10 | [Exercise \#1](https://github.com/KeithGalli/regular-expressions/blob/master/examples/meme-example.txt): Write a regex to match meme text format
11 | [Exercise \#2](https://github.com/KeithGalli/regular-expressions/blob/master/examples/date-matching.txt): Write a regex to match a specific date format
12 | [Exercise \#3](https://github.com/KeithGalli/regular-expressions/blob/master/examples/advanced-sentence-examples.txt): Detect if the same word pops up in a sentence multiple times
13 | [Exercise \#4](https://github.com/KeithGalli/regular-expressions/blob/master/examples/password_regex_match.txt): Password matching with rules
14 |
15 | ## Resources
16 |
17 | Here are some resources I find useful when learning regular expressions:
18 | - [Regex101.com](https://regex101.com)
19 | - [Regex cheat sheet](https://cheatography.com/davechild/cheat-sheets/regular-expressions/)
20 | - [Regex golf practice exercises](https://alf.nu/RegexGolf)
21 | - [Interactive learning walkthrough](https://regexlearn.com/)
22 | - [Lookaheads & Lookbehinds Info](https://javascript.info/regexp-lookahead-lookbehind)
23 |
--------------------------------------------------------------------------------
/examples/advanced-sentence-examples.txt:
--------------------------------------------------------------------------------
1 | Code Man's code is so efficient, he once saved a client $10,000 by deleting a single semicolon.
2 | In the heat of battle, Syntax Slayer would code so furiously that his keyboard would catch fire.
3 | Regex Rex could spot a misplaced semicolon from a mile away, no problem.
4 | At precisely 2:47PM, ByteBoy finished debugging his program and saved the company $1 million.
5 | With her lightning-fast typing skills, Keyboard Queen can code circles around her coworkers. Literally, she once wrote a program that made the computer screen display a rotating circle of text that read 'I'm faster than you'.
6 | The legendary programmer known only as 'Barbarian Bob' was feared by his colleagues for his ruthless coding style. He once wrote an algorithm that duplicated the word 'barbarian' 100 times, just to prove a point.
7 | Cash Coder never works for free. His hourly rate is $1,000. But don't worry, he's worth every penny. He once coded a program that made a toaster sing 'Sweet Child O' Mine' every time it popped.
8 |
9 |
--------------------------------------------------------------------------------
/examples/date-matching.txt:
--------------------------------------------------------------------------------
1 | MM-DD-YYYY (or MM.DD.YYYY -- MM/DD/YYYY)
2 |
3 | 06-04-2000
4 | Christmas this year is 12/25/2023
5 | 02-22-2022
6 | Humans first stepped on the moon July 20, 1969
7 | 10/31/99
8 | A great movie came out on 02.16.1996
9 |
10 |
--------------------------------------------------------------------------------
/examples/meme-example.txt:
--------------------------------------------------------------------------------
1 | KeItH sAyS yOu NeEd To LeArN rEgExEs
2 |
3 | wElCoMe To ThE sAlTy SpItOoN, hOw ToUgH aRe YoU?
4 |
5 | This is a boring, normal sentence.
6 |
7 | lEt Me SeE tHaT sPoNgEbOb MeMe OnE mOrE tImE
8 |
--------------------------------------------------------------------------------
/examples/password_regex_match.txt:
--------------------------------------------------------------------------------
1 | Exercise #4: Write a Regex to Enforce
2 | Password Requirements...
3 |
4 | 1. Must contain one lower-case letter
5 | 2. Must contain one upper-case letter
6 | 3. Must contain a number
7 | 4. Must contain one these symbols !@#$%
8 | 5. Must be greater than 8 characters
9 |
10 | password
11 | YoYoYoYo
12 | 12389275
13 | wolfRhino123
14 | cat
15 |
16 | *jaslfkjlFJKKJ32342
17 | Charlie12@
18 | 432Yy123!!!!
19 | !@#abcABC2
20 | aaAA00!!!!
21 |
--------------------------------------------------------------------------------
/examples/regex-advanced.txt:
--------------------------------------------------------------------------------
1 | 1, 2, 3, 4, 5
2 |
3 | $9 $12 $1,000 $10,000 $3 million
4 | $60 trillion
5 | 9:30am 10am 1pm 7:45pm 11:20 PM 11:35 pm
6 |
7 |
--------------------------------------------------------------------------------
/examples/regex-basics.txt:
--------------------------------------------------------------------------------
1 | ABCDEFGHIJKLMNOPQRSTUVWXYZ
2 | abcdefghijklmnopqrstuvwxyz
3 | 0123456789
4 |
5 | ace bad cat dry eve
6 | away bent crow dove ends
7 | attic brand crypt dried event
8 | annoys baller camera diving ethics
9 |
--------------------------------------------------------------------------------
/examples/regex-groups.txt:
--------------------------------------------------------------------------------
1 | 123456789
2 | 999000999
3 | 8712388411235
4 |
5 | mississippi
6 | bookkeeping
7 | aggressive
8 | words
9 |
10 |
--------------------------------------------------------------------------------
/examples/regex-sentence-examples.txt:
--------------------------------------------------------------------------------
1 | ~`!@#$%^&*()-_+=<>,./?;:'"[{
2 | 0123456789
3 |
4 | In the future:
5 |
6 | your toaster will be smarter than you.
7 | Robots will take over the world, but they'll do it in style.
8 | Augmented reality will let you pet virtual unicorns in your living room.
9 | Quantum computing will allow you to calculate the meaning of life in seconds.
10 | Blockchain will make your online shopping experience more secure than Fort Knox.
11 | Cybersecurity will be so advanced, hackers will have to resort to using actual swords.
12 | In the future, we'll all communicate through a universal language made up entirely of emojis.
13 |
14 |
--------------------------------------------------------------------------------