REGEX REPASO Regex** Regular Expressions** Used to find patterns within a string. | --> Logical or ( ) --> Grouping ? --> Allow 0 or 1 Times " * " --> 0 or multiple times {min, max} Validate text. Searching through text.
\d --> any digit \w --> Any word character \D --> Anything not digit [ ] --> character set ^ --> Negate, doing the opposite source: https://www.youtube.com/watch? v=sXQxhojSdZM https://regexr.com/ What are regular expression? Its a way to search through a text. To validate it or get pieces of it.
Format: Almost always between / / After the forward slash, you can put expression flags. Find Replace Validate
fuente: regexr.com Special Characters "+" --> One or more than one
Example: e+ Match one e or more than one "?" --> Optional (optional) 0 or 1
it gets an e character where there is one, and if there is also an a character, it gets that too. So there can be 0 or 1 a character. " * " --> get 0 or more, its the same as before with the ?, but now it can be as many as you want.
Not just 1. " . " --> anything, just whatever get it all. Except line breaks. new lines
\w --> match any word character.
\W --> Anything that is not a character. \s --> Matches any form of whitespace
\S --> Anything that is not whitespace Remember in these examples we are using the g flag after the forward slash so its taking into account everything {min, max} Get all the words with 4 digits
Get all the words with 4 digits or more Get words with 4 to five digits Match between 4 and 5 of the preceding token. Any set of characters between 4 and 5. Character Groupings [ ] Matches any character in the set.
a to z
a s S
Looks for this characters all over, because they are inside of the square brackets. [ ] All the characters between a and z (lower case) All the characters between A and Z (Upper Case)
Anything between a and f.
Some examples of ranges with numbers
Parenthesis Put things inside of a group. They only act upon themselves.
T or t Uppercase or lower case T
the parenthesis make it possible to use the logical or, only on the t, and not in the "he", of the word "the". So in this case you will get the word "the", with a lowercase or an uppercase "T".
It matches 2 "t" or "T", but no more than that. It matches 2 to 3 ts, and Ts, but not 4. It doesnt seem to matter that there is not a
separation by a whitespace, so if there are 6 ts, its gonna select them, but if there are 7, its just gonna select 6. Anything you put after this grouping is gonna affect the whole grouping. if the "re" was out of the parenthesis, the range would just affect the "e" character, but because "re" is inside of the parenthesis eveything is affected. cont..... The beginning of the statement ^
^ --> Match the begging of the statement Begins with S So this matches the beginning of everything, if you want it to take into account each line, you will have to put the multiline expression flag at the
end "m".
Even if there is ReGex in another part of the test, it's just gonna look for the one in the very beginning. The end $ Match the end of the statement.
The periods at the end of the line. (if there is a space after the period its not gonna select it )
Look ahead and look behind Look at things that happened before or after the thing that you capture. Look behind Positive look behind (?<=)
< --> it says look behind this = --> says it is positive Every single word that is precede by the word the Negative Look behind Instead looks for everything that doesnt have the word "the" before. You replace the equals sign with the ! exclamation sign.
Look ahead We just have to remove the less than symbol Source: https://www.youtube.com/watch? v=rhzKDrUiJVk&t=37s Any character that's followed by "at"
Everything that's not followed by "at" A regular expression to check for a phone number
Recursos de Canvas
Ejemplos How Regex Works
Metacharacters To specify regular expressions, metacharacters are used. They are interpreted in a special way by a regex engine.