Regex Tester Homework
Overview:
For this homework, you will use the regex tester found at http://www.zytrax.com/tech/web/regex.htm . You will write one sentence, and then make up 5 search patterns that use the regular expression commands we learned in class:
· anchors of ^ and $
· use the . dot to mean any character
· use a class to mean any character inside the brackets [ ]
You will then create a word document that contains your sentence, your search strings and a copy of the results of each search.
Please also read http://www.zytrax.com/tech/web/regex.htm I hope you to follow well in the beginning, but if it gets confusing after "more stuff" that is okay.
Exact Steps:
1. Find the tester box:
· go to http://www.zytrax.com/tech/web/regex.htm
· Search for "If you plan to experiment with the target strings"
· scroll down one screen to see the String, Re and Results box to see the box below:
2. Write one sentence, any sentence in the String box, and copy that to a new word document
3. Write a search expression to test matching to your sentence into RE, and copy that into the word document
· maybe write one regex search expression that will match the end of the line, and put $ to indicate end of line
· maybe Write one regex search expression that would have matched a word, but fails because you put $
· maybe write one regex search expression that looks for the first letter of a word in your sentence and then any 2 characters (..) and then the fourth letter
· Here is where you experiment with . ^ $ and [ ]
· Remember you are experimenting with:
·
anchors of ^ and $ - ^ is beginning of line and
$ is end of line
·
use the
. dot to mean any character
· use a class to mean any character inside the brackets [ ]
· Example:
4. click search to see the results box fill, and copy the results into the word document.
5. repeat 5 times with the same sentence (so repeat 3-4)
6. upload the document to moodle.
Sample Document for homework: (This uses my sentence and my searches. You use your own.)
The cats fight every morning and wake me up at 5:30 am.
RE: wake$
Result: no match
RE: am.$
result: The cats fight every morning and wake me up at 5:30 <am.>
First match: am. at position 53
RE: c.t
Result: The <cat>s fight every morning and wake me up at 5:30 am.
First match: cat at position 5
RE: .... (note with a space before and after)
Result: The< cats >fight every morning and wake me up at 5:30 am.
First match: cats at position 4
Additional matches:
Found: wake at position 33
Found: 5:30 at position 47
RE: [every]
Th<e> cats fight every morning and wake me up at 5:30 am.
First match: e at position 3
Additional matches:
Found: e at position 16
Found: v at position 17
Found: e at position 18
Found: r at position 19
Found: y at position 20
Found: r at position 24
Found: e at position 37
Found: e at position 40