Regular expressions

Online Courses

Regular Expressions
Regular Expressions may be used to test if a string (Text) is according to a certain grammar. Sometimes Regular Expressions are called regex or regexp.  We can easily test if a string contains another string:

You can also test if a string does not contain a substring:

Grammar
We may define a grammar, to match against any input string. Let’s say we want to match against three digits, we would define a gramamr ‘\d{3}\Z’. Example:

This will out put “True” if the string s matches the grammar string.

Grammar rules
The permitted grammar for regular expressions is: