User Tools

Site Tools


eg-259:homework:9

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
eg-259:homework:9 [2012/02/17 12:18] – [Text Processing with Regular Expressions] eechriseg-259:homework:9 [2012/02/22 13:58] (current) – [3. Practical Exercises] eechris
Line 12: Line 12:
   - //Input//: A text string, using ''prompt''; //Output//: The words of the input text, in alphabetical order   - //Input//: A text string, using ''prompt''; //Output//: The words of the input text, in alphabetical order
   - //Function//: ''tst_name''; //Parameter//: a string; //Returns//: ''true'' if the given string has the form: ''string1, string2, letter'' where both strings must be all lowercase letters except the first letter, and //letter// must be uppercase; ''false'' otherwise.   - //Function//: ''tst_name''; //Parameter//: a string; //Returns//: ''true'' if the given string has the form: ''string1, string2, letter'' where both strings must be all lowercase letters except the first letter, and //letter// must be uppercase; ''false'' otherwise.
 +  - Use the function developed in Exercise 3 to validate a form with a text field that captures the user's name when the user presses the submit button. The form should not submit data if the name is not in the correct format. Use the example given in the session as a template.
 +  - Repeat exercise 4 using the built-in HTML5 ''pattern'' attribute to validate the name as defined in Exercise 3.
  
  
Line 32: Line 34:
 ===== 3. Practical Exercises ===== ===== 3. Practical Exercises =====
  
-  * Copy and paste the following text into the //Target// window of [[/eg-259/examples/lecture7/JRX.html|JRX]]+  * Copy and paste the following text into the //Target// window of [[/eg-259/examples/lecture7/regexpal/index.html|RegexPal]] or [[/eg-259/examples/lecture7/JRX.html|JRX]]
  
-    The quick brown fox jumped over the lazy dog. +  Xooo 
-     +  oXoo 
-    Xooo +  ooXo 
-    oXoo +  oooX 
-    ooXo +   
-    oooX +  ABCDEFGHIJKLMNOPQRSTUVWXYZ 
-     +  abcdefghijklmnopqrstuvwxyz 
-    ABCDEFGHIJKLMNOPQRSTUVWXYZ +  0123456789 `|\<>,./?#~'@;:[]{}=+-_)(*&^%$£"
-    abcdefghijklmnopqrstuvwxyz +   
-    0123456789 `|\<>,./?#~'@;:[]{}=+-_)(*&^%$£"+  +44 (1792) 295580 
-     +   
-    555-789-1234 +  some.one@swan.ac.uk 
-     +   
-    some.one@swan.ac.uk +  Some wiki text with words in //italic// and **bold**. Like //this// or **that**. 
-     +   
-    Some wiki text with words in //italic// and **bold**. Like //this// or **that**. +  ---- 
-     +  Alice was beginning to get very tired of sitting by her sister on the bank, and of having 
-    Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into   +  nothing to do: once or twice she had peeped into the book her sister was reading, but it 
-    the book her sister was reading, but it had no pictures or conversations in it, `and what is the use of a book,' thought Alice `without  +  had no pictures or conversations in it, `and what is the use of a book,' thought Alice 
-    pictures or conversation?' +  `without pictures or conversation?' 
-     +   
-    So she was considering in her own mind (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure  +  So she was considering in her own mind (as well as she could, for the hot day made her 
-    of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran  +  feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth 
-    close by her. +  the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink 
-     +  eyes ran close by her. 
-    There was nothing so very remarkable in that; nor did Alice think it so very much out of the way to hear the Rabbit say to itself, `Oh  +   
-    dear! Oh dear! I shall be late!' (when she thought it over afterwards, it occurred to her that she ought to have wondered at this, but at  +  There was nothing so very remarkable in that; nor did Alice think it so very much out of 
-    the time it all seemed quite natural); but when the Rabbit actually took a watch out of its waistcoat-pocket, and looked at it, and then  +  the way to hear the Rabbit say to itself, `Oh dear! Oh dear! I shall be late!' (when she 
-    hurried on, Alice started to her feet, for it flashed across her mind that she had never before seen a rabbit with either a waistcoat- +  thought it over afterwards, it occurred to her that she ought to have wondered at this, 
-    pocket, or a watch to take out of it, and burning with curiosity, she ran across the field after it, and fortunately was just in time to  +  but at the time it all seemed quite natural); but when the Rabbit actually took a watch 
-    see it pop down a large rabbit-hole under the hedge. +  out of its waistcoat-pocket, and looked at it, and then hurried on, Alice started to her 
 +  feet, for it flashed across her mind that she had never before seen a rabbit with either a 
 +  waistcoat- pocket, or a watch to take out of it, and burning with curiosity, she ran 
 +  across the field after it, and fortunately was just in time to see it pop down a large 
 +  rabbit-hole under the hedge. 
 +  ---- 
 +   
 +  End of File
  
   * Write regular expressions to match:   * Write regular expressions to match:
     - any non-blank line of text.     - any non-blank line of text.
-    - any word.+    - any //proper// word((That is as we normally understand the term ... not the ''\w'' definition)).
     - the telephone number.     - the telephone number.
     - ''"X"'' followed by up to two ''"o"'' characters     - ''"X"'' followed by up to two ''"o"'' characters
Line 75: Line 84:
     - any lowercase consonant     - any lowercase consonant
     - any punctuation character     - any punctuation character
-    - The domain name of the email address. +    - the email address 
-    - The user name of the email address. +    - the domain name of the email address. 
-    - The words in italics in the wiki text. +    - the user name part of the email address. 
-    - The start of each sentence in the quotation from Alice in Wonderland.+    - the words in italics in the wiki text. 
 +    - the start of each sentence in the quotation from Alice in Wonderland.
  
   * Take any (or all) of the example JavaScript programs from the last three lectures and explore them in //Firebug// using the console, console logger and debugger.   * Take any (or all) of the example JavaScript programs from the last three lectures and explore them in //Firebug// using the console, console logger and debugger.
eg-259/homework/9.1329481139.txt.gz · Last modified: 2012/02/17 12:18 by eechris