Capital City Christian Church
PluggedIn IT Ministry




Regular Expressions (Regex)

Resourses to work through and cite

https://regexr.com/
https://www.regular-expressions.info/
https://www.rexegg.com/
https://medium.com/factory-mind/regex-tutorial-a-simple-cheatsheet-by-examples-649dc1c3f285
https://www.regular-expressions.info/tutorial.html
https://cheatography.com/davechild/cheat-sheets/regular-expressions/
https://www.rexegg.com/

'A regular expression (shortened as regex or regexp; also referred to as rational expression) is a sequence of characters that specifies a search pattern.' (Tuesday 12.07.2021 21:37:29 https://www.google.com/search?q=regular+expression+meaning)

In many programming languages, a regular expression is a pattern that matches strings or pieces of strings.

A regular expression (sometimes called a rational expression) is a sequence of characters that define a search pattern, mainly for use in pattern matching with strings, or string matching, i.e. “find and replace”-like operations. ... Regular expressions are a generalized way to match patterns with sequences of characters

Examples of the above parameters;

┌──(parth㉿Parth)-[~]
└─$ grep '^John 3:16' bible.txt
John 3:16	For God so loved the world, that he gave his only begotten Son,
that whosoever believeth in him should not perish, but have everlasting life.

Notice the difference when using single or double quotes.

┌──(parth㉿Parth)-[~]
└─$ grep 'the Lord lay\.$' bible.txt

┌──(parth㉿Parth)-[~]
└─$ grep "the Lord lay." bible.txt
Matthew 28:6	He is not here: for he is risen, as he said. Come, see the place where the Lord lay.

The following will find Jesus, Jews, Jezebel, Jerusalem...

┌──(parth㉿Parth)-[~]
└─$ grep -i "je." bible.txt

in many programming languages, a regular expression is a pattern that matches strings or pieces of strings.

A regular expression (sometimes called a rational expression) is a sequence of characters that define a search pattern, mainly for use in pattern matching with strings, or string matching, i.e. “find and replace”-like operations. ... Regular expressions are a generalized way to match patterns with sequences of characters

^Thematches any string that starts with The
end$matches a string that ends with end
^The end$exact string match (starts and ends with The end)
abc*matches a string that has ab followed by zero or more c
abc+matches a string that has ab followed by one or more c
abc?matches a string that has ab followed by zero or one c
abc{2}matches a string that has ab followed by 2 c
abc{2,}matches a string that has ab followed by 2 or more c
abc{2,5}matches a string that has ab followed by 2 up to 5 c
a(bc)*matches a string that has a followed by zero or more copies of the sequence b
ca(bc){2,5}matches a string that has a followed by 2 up to 5 copies of the sequence bc
a(b|c)matches a string that has a followed by b or c (and captures b or c)
\dmatches a single character that is a digit
\wmatches a word character (alphanumeric character plus underscore)
\smatches a whitespace character (includes tabs and line breaks)
.matches any characte
\Dmatches a single non-digit character
\$\dmatches a string that has a $ before one digit
[abc]matches a string that has either an a or a b or a c
[a-c]same as previous
[a-fA-F0-9]a string that represents a single hexadecimal digit, case insensitively
[0-9]%a string that has a character from 0 to 9 before a % sign
[^a-zA-Z]a string that has not a letter from a to z or from A to Z. In this case the ^ is used as negation of the expression