You might want read the post on Regexp Builder before attempting these…
Here’s an example of a British Postcode: OL1 3SQ. It has the format 2 letters and a digit, space, 1 digit and two letters. The following emacs regex finds this type of postcode:
- Write a regex to find postcodes of the type W1 1AA
- Write a regex to find postcodes of the type RM12 4JJ
- Write one regex that finds all three types of postcode: OL1 3SQ, W1 1AA and RM12 4JJ
- Write a regex that finds simple email addresses of the form email@example.com
- Now extend the regex to find email addresses of the form firstname.lastname@example.org
- Now write a general email regex that will find all properly formed email addresses
- Google the form of an ISBN (There are two standards). Write a regex to find ISBNs
- Write a regex that can find unnecessary white space in a line of text
This line has unnecessary white space .
| So does this line |
This line does not.
“He said ‘Have you got the time?’” “Why didn’t he look at his watch?”
Write a regex that can find the left single quotes: ‘and right double quotes: ” in the above conversation.