Javascript has many methods that tell us if a string contains a certain character or term. Take a look at this example below. 'Ruben Castro is the Shift Lead' ends with ('Shift Lead') This method is ok most of the time but it does have some flaws. What if you needed to find a string with have the word "Shif Leads" and not just one "Shift Leads". These issues can be solved with additional statements that go more in depth and require parameter that you want, or you can turn them into a regular expression and make it easy for you.
Regular Expressions, also known as Regex are patterns used to match character combinations in strings. Regex lets you search and manupilate text strings. Regex is good because it saves you alot of time when writing code.
A part of a pattern can be enclosed in parentheses (...) . This is called a “capturing group”. That has two effects: It allows to get a part of the match as a separate item in the result array.
A bracket expression represents a character set via a list of characters enclosed by the square brackets: '[' and ']' If it matches data character from the list to match the target string.
Character classes can tell the difference letters and digits and much more.
Here are 2 examples of character classes:
\s: Matches whitespace character.
\t: Matches a tab.
You can do very specific and detailed searches . For example if you use the following \..
The \. allows us to find not just any character, but with just a dot you can access data inside that folder.
My name is Ruben Castro and if you want to check out my work do so here --> https://github.com/RubenCastroCoding