Monday, April 26, 2021

Practice with Regular Expressions

^[a-z]*p[a-z\s]{1}t[a-z]*$
^ indicates the beginning of a string or line, and $ indicates the end
/s is space

                           [a-z] means any of the lower case letters a-z
                           [a-z]* means any of the lower case letters a-z repeated 0 or more times
                               This is followed by the letter p
                               [a-z\s]{1} means any of the lowercase letters a-z or space exactly one time
                               This is followed by the letter t. (Exactly one lowercase letter or space is between the p and t in the column on the left
                               [a-z]* means any of the lower case letters a-z repeated 0 or more times after the t
                               and $ means you reached the end of the string.


This book has a free trial:
https://www.oreilly.com/library/view/mastering-regular-expressions/0596528124/

 https://www.oreilly.com/library/view/mastering-regular-expressions/0596528124/pref00.html

This is the web site for the third edition of Mastering Regular Expressions, by Jeffrey Friedl. http://regex.info/book.html errors in each edition and downloadable code, including egrep

 

When your language definition accepts an empty string then your language is Nullable. If your language is Nulla​ble, then your language accepts the empty string.

iff = with three lines is a definition if and only if
A rectangle is a square when there are equal length sides and 90' angles
A square is a rectangle with equal length sides and 90' angles


Here is a practice sheet:


This has a phone number example at the end:

No comments:

Post a Comment