About 4 hours
- 30 minutes for video walkthrough of slides
- 180 minutes for Independent Practice
- 30 minutes for checking understanding
- JS 1 lesson
- JS 2 lesson
- JS 3 lesson
- JS 4 lesson
- Regular Expressions allow you to search and modify strings using a special language. They are very powerful and can enable writing significantly less code.
Apprentices will be able to:
- Read and write RegEx in Javascript
- Use RegEx to test and replace strings
- Understand basic regular expression special characters:
.*+?\w\d
- JavaScript's RegExp syntax/structure
- Basic regular expression characters
- How RegExp modifiers work
- The 4 string methods and 2 RegExp methods that work with RegExps
- Regular Interactive Visualizer and Tester
- Javascript Regular Expressions (MDN)
- Javascript Regular Expressions (W3 Schools)
- JavaScript RegExp Reference (W3 Schools)
- RegExp (Eloquent Javascript)
- There are two ways to use RegEx:
- RegEx as input to 4 String methods:
String.replace()
,String.match()
,String.search()
,String.split()
- String as input to 2 RegEx methods:
RegExp.test()
,RegExp.exec()
- RegEx as input to 4 String methods:
- You can add modifiers to RegEx
- The pattern goes between the two forward slashes, and you can use back slashes to escape special characters
- There are a lot of complex RegEx patterns. We'll teach the basic ones, but there are many more you can learn as you go.
Instructor demonstrates in the video walk through how to work with Regular Expressions in JavaScript.
- Go through the tutorial at https://regexone.com. Do at least lessons 1-10. This isn't Javascript specific, but it will help you understand how to match text with regular expressions.
- Write a function that takes a word and returns true if the word ends with
tonica
- Write a function expression that takes a string replaces all instances of
symantec
withsemantic
? - Write a function that takes a string and deletes all words that end in
ing
? - Write a function that takes a string and returns true if it is an email address? Compare your answer with your neighbor.
- Write a function that takes a string containing names separated by commas like
"Leah, Russell, Michelle"
and returns an array of names,["Leah", "Russell", "Michelle"]
- Write a regular expression that matches any participant name, but not any staff name
- What about a regular expression for all even-length strings?
- Do lessons 11+ on https://regexone.com
- Make a cheat sheet to remind yourself about the different regular expression characters and how to use them.