My therapy appointment was rescheduled to 2:30pm tomorrow rather than 10am. I’d rather do the morning but oh well. I guess the therapist was double booked. And I just got the confirmation text now and the way it is written you’d think I was the one who keeps rescheduling. I’m kind of annoyed at that. During my therapy I use my phone but I was thinking… if I use my iPad, I won’t have to spend an hour holding up my device. Yes, I think I will do that tomorrow. Usually I’m in the office during my appointment but Kel will be home so I may have to have my appointment in the bedroom. Ok, I confirmed my appointment. I’m still a little nervous about therapy and what to talk about. I know I have a lot to talk about concerning my past and with the new therapist I have to start at the beginning. It just sucks having to start over.
This morning Merlin was chasing Sandy around and cornered her. Sandy reached out and swiped his ear. He has a wound now and you’d think this would teach him not to chase her. But no, he is still chasing the cat. All the while Sandy is hissing at him whenever he is around her. Merlin is getting big. He is 10 weeks old now.
Right now I am reading, Tomorrow, and tomorrow, and tomorrow. I’m only 3% into the book but so far the story has intrigued me. This book was really hyped up on GoodReads so I’m hoping it will live up to that.
Regular expressions in JavaScript are giving me Linux vibes. While it isn’t that close to Linux, it somehow gives me the vibe.
———————————–
You’ve learned that you can use a shortcut to match alphanumerics [A-Za-z0-9_] using \w. A natural pattern you might want to search for is the opposite of alphanumerics.
You can search for the opposite of the \w with \W. Note, the opposite pattern uses a capital letter. This shortcut is the same as [^A-Za-z0-9_].
let shortHand = /\W/; let numbers = "42%"; let sentence = "Coding!"; numbers.match(shortHand); sentence.match(shortHand);
The first match call would return the value [“%”] and the second would return [“!”].
You’ve learned shortcuts for common string patterns like alphanumerics. Another common pattern is looking for just digits or numbers.
The shortcut to look for digit characters is \d, with a lowercase d. This is equal to the character class [0-9], which looks for a single character of any number between zero and nine.
The last challenge showed how to search for digits using the shortcut \d with a lowercase d. You can also search for non-digits using a similar shortcut that uses an uppercase D instead.
The shortcut to look for non-digit characters is \D. This is equal to the character class [^0-9], which looks for a single character that is not a number between zero and nine.
Usernames are used everywhere on the internet. They are what give users a unique identity on their favorite sites.
You need to check all the usernames in a database. Here are some simple rules that users have to follow when creating their username.
Usernames can only use alpha-numeric characters.
The only numbers in the username have to be at the end. There can be zero or more of them at the end. Username cannot start with the number.
Username letters can be lowercase and uppercase.
Usernames have to be at least two characters long. A two-character username can only use alphabet letters as characters.
The challenges so far have covered matching letters of the alphabet and numbers. You can also match the whitespace or spaces between letters.
You can search for whitespace using \s, which is a lowercase s. This pattern not only matches whitespace, but also carriage return, tab, form feed, and new line characters. You can think of it as similar to the character class [ \r\t\f\n\v].
let whiteSpace = "Whitespace. Whitespace everywhere!" let spaceRegex = /\s/g; whiteSpace.match(spaceRegex);
This match call would return [” “, ” “].
You learned about searching for whitespace using \s, with a lowercase s. You can also search for everything except whitespace.
Search for non-whitespace using \S, which is an uppercase s. This pattern will not match whitespace, carriage return, tab, form feed, and new line characters. You can think of it being similar to the character class [^ \r\t\f\n\v].
let whiteSpace = "Whitespace. Whitespace everywhere!" let nonSpaceRegex = /\S/g; whiteSpace.match(nonSpaceRegex).length;
The value returned by the .length method would be 32.
Recall that you use the plus sign + to look for one or more characters and the asterisk * to look for zero or more characters. These are convenient but sometimes you want to match a certain range of patterns.
You can specify the lower and upper number of patterns with quantity specifiers. Quantity specifiers are used with curly brackets ({ and }). You put two numbers between the curly brackets – for the lower and upper number of patterns.
For example, to match only the letter a appearing between 3 and 5 times in the string ah, your regex would be /a{3,5}h/.
let A4 = "aaaah"; let A2 = "aah"; let multipleA = /a{3,5}h/; multipleA.test(A4); multipleA.test(A2);
The first test call would return true, while the second would return false.