Day 11: Matching Strings of Characters with Regular Expressions
#100DaysOfCode Challenge

Search for a command to run...
#100DaysOfCode Challenge

No comments yet. Be the first to comment.
How Perseverance Led Me to Data Analytics

An SQL cheat sheet for beginners

My top learning resources and why I like them

A how-to- guide with code snippets and a live demo

My Top 7 Git Commands and How I Use Them

Photo by Clément Hélardot on Unsplash
Today I worked on the Regular Expressions section (61% done so far). The challenges were all focused on using regular expressions (no surprise there!) to match strings of characters. Here are my notes from today’s session:
/apple/i will match all cases of the string 'apple' such as apple, Apple, aPPle, etc..match() method."g"/search/gi". will match any one character. The wildcard is also called dot and period. You can use the wildcard character just like any other character in the regex. For example, if you wanted to match hug, huh, hut, and hum, you can use the regex /hu./ to match all four words."bag, big, and bug but not bog. You can create the regex /b[aiu]g/ to do this. The [aiu] is the character class that will only match the characters a, i, or u."-. For example, to match lowercase letters a through e you would use [a-e]."-) to match a range of characters is not limited to letters. It also works to match a range of numbers. For example, /[0-5]/ matches any number between 0 and 5, including the **0** and **5**."/[h-s2-6]/ will match the letters h through s and the numbers 2 through 6.^) after the opening bracket and before the characters you do not want to match. For example, /[^aeiou]/gi matches all characters that are not a vowel. "/a+/g would find one match in abc and return ["a"]. Because of the +, it would also find a single match in aabc and return ["aa"]."+ sign is used to check if a character occurs one or more times, the * sign can be used to check if a character occurs zero or more times.? character to change it to lazy matching.^ carrot character to search the beginning of strings, but to search the end of a string you would use the $ dollar symbol at the end (e.g., /story$/ will look for the string story at the end of a string like This is the end of the story and return a true value)\w is used in place of [A-Za-z0-9_] to search for alphanumeric characters.!, %, etc.) we can use \W which is equivalent to [^A-Za-z0-9].\d, with a lowercase d. This is equal to the character class [0-9]
Photo by Kenny Eliason on Unsplash
Overall I’m feeling pretty confident about today’s study session. The regular expressions haven’t been too difficult for me, though I have seen them before in my study of Python — but that was a while ago so I’m appreciating the review in these challenges.
I didn’t listen to music during today’s session — my hour of coding was broken up in to small segments at work and at home. I squeezed in the time wherever I could which worked pretty well. There’s something relaxing about working on coding challenges, it’s a nice break from the ‘day job’. Looking forward to learning more.
For my progress visit the timeline on my freeCodeCamp Profile.
The full log of my #100DaysOfCode journey can be viewed on GitHub.