Please enable JavaScript.
Coggle requires JavaScript to display documents.
Chapter 10.1.2 - Regular Expressions (Key Patterns (0-9: looks for exact…
Chapter 10.1.2 - Regular Expressions
What is RegEx?
Regular Expressions are a tool for finding, replacing or extracting content from text
Extracting phone numbers
numbers and letters can be specified
555 or abc, etc.
goal of RegEx is to extract instances of specified pattern in a string
allows for creation of new column containing TRUE or FALSE (pattern matched or not)
Key Patterns
0-9: looks for exact digits you specify
a-z or A-Z: looks for exact letters you specify
\d: any one digit
\D: any character EXCEPT FOR digits
\w: any alphanumeric character (0-9, a-z)
\W: any NON alphanumeric character (symbols - a*%)
. : any character
?: character before question mark is optional
\s: any whitespace - space, return, etc
\S: anything but whitespace
[]: any alphanumeric character listed within the brackets
[^]: any alphanumeric character NOT listed after the caret
| : pattern on either side of pipe selects a match if they are found
ab$: $ specifies end of string being examined
^ab: caret specifies beginning of string being examined
*: zero or more repetitions
+: one or more repetitions
{m} : pattern proceeding curly brackets should occur "m" times
{m,n}: pattern proceeding brackets should repeat "m" to "n" times
(): capture the strings that fit the pattern
Special Patterns
a[Ga]c: hard brackets specify that one character in specific position can be any character listed in bracket
a{^Ga}c: caret at start inside brackets specifies character listed cannot exist