The address for this web page is:   www.crosswinds.net/~fishcaro/day_J10_regular_expressions.htm
On to the next lesson!
Back to the COURSE SYLLABUS

J10. PRACTICE WITH REGULAR EXPRESSIONS


In this section, you'll practice creating regular expressions that achieve desired search results. The answers are embedded in the source code, so you can VIEW the source code if you get stumped. However, only look after you've tried yourself!

from PATTERNS through middle of page 86
from "There's also a negated character class..." through "If you need to say ..." in the middle of page 87
from "If you need to say..." on page 87, up to "Parentheses as memory" on page 88
from "Parentheses as memory" on page 88, up to "Anchoring Patterns" on page 90
from "Anchoring Patterns" on page 90, up to "Precedence" on page 91


Please read from PATTERNS through the middle of page 86 (up to "There's also a negated...") in the class handout.

Create an HTML document containing the following code:

<script language="JavaScript">
string = "\"The quick brown fox jumps over the lazy dog,\" she said. That's that: 3 more to go!";
retv = string.match(/a/g);
document.write(string,"<BR>");
document.write("returned values: ",retv,"<BR>");
</script>

This code returns the following; note that it located all the letters "a" in the search string:

Now, you'll change the regular expression "/a/g" to achieve the following results:




Please read from "There's also a negated character class..." through "If you need to say ..." in the middle of page 87 in the class handout. These exercises will give you practice with this material.

Create an HTML document containing the following code:

<script language="JavaScript">
string = "\"The quick brown fox jumps over the lazy dog,\" she said. THAT'S THAT: 3 more to go!";
retv = string.match(/a/g);
document.write("string: ",string,"<BR>");
document.write("returned values: ",retv,"<BR>");
</script>




Please read from "If you need to say..." on page 87, up to "Parentheses as memory" on page 88. These exercises will give you practice with this material.

Create an HTML document containing the following code:

<script language="JavaScript">
string = "different regular expressions will go here";
retv = string.match(/a/g);
document.write("string: ",string,"<BR>");
document.write("returned values: ",retv,"<BR>");
</script>


You'll be changing both the string = and the retv = lines for each of these exercises.




Please read from "Parentheses as memory" on page 88, up to "Anchoring Patterns" on page 90. (You can leave off the paragraph: "Another use of memorized parts ... in between.") These exercises will give you practice with this material.

Create an HTML document containing the following code:

<script language="JavaScript">
string = "different regular expressions will go here";
retv = string.match(/a/g);
document.write("string: ",string,"<BR>");
document.write("returned values: ",retv,"<BR>");
</script>


You'll be changing both the string = and the retv = lines for each of these exercises.




Please read from "Parentheses as memory" on page 88, up to "Anchoring Patterns" on page 90. (You can leave off the paragraph: "Another use of memorized parts ... in between.") These exercises will give you practice with this material.

Create an HTML document containing the following code:

<script language="JavaScript">
string = "different regular expressions will go here";
retv = string.match(/a/g);
document.write("string: ",string,"<BR>");
document.write("returned values: ",retv,"<BR>");
</script>


You'll be changing both the string = and the retv = lines for each of these exercises.




Please read from "Anchoring Patterns" on page 90, up to "Precedence" on page 91. These exercises will give you practice with this material.

Create an HTML document containing the following code:

<script language="JavaScript">
string = "different regular expressions will go here";
retv = string.match(/a/g);
document.write("string: ",string,"<BR>");
document.write("returned values: ",retv,"<BR>");
</script>


You'll be changing both the string = and the retv = lines for each of these exercises.

On to the next lesson!
Back to the COURSE SYLLABUS
© 2001 Carol J.V. Fisher    All Rights Reserved