31.4. Assignments Regular Expressions

Submission
You must submit assignments using git
Create Repo
  • Create an empty repo on bitbucket.org, gitlab.com, or github.com,
  • git push your local repo to the above remote repo.
  • For node assignments the line node_modules/must be in your .gitignore file.
Submit
By email to with:
  • The word 'submission <subjectname>' in the subject line
  • The url(s) of your repo(s) in the body

31.4.1. Assignment JS.Regex.0

Write a regular expression that extracts the domain name portion of a Web URL (excluding the “ www. ” subdomain if supplied). The protocol portion of the URL should be optional. For example, the expression should extract the domain name “ example.com ” from any of the following URLs:

  • http://www.example.com/
  • http://www.example.com/hello/there.html
  • http://example.com/hello/there.html
  • www.example.com/hello/there.html
  • https://www.example.com

31.4.2. Assignment JS.Regex.1

Enhance the script displayed earlier at Example 31.13 to display not just the URL of each link, but also the link text (the text between the < a > and < /a > tags).

31.4.3. Assignment JS.Regex.2

Make an HTML5/JavaScript page documenting whether the special characters 'æ', 'ø', and 'å', and perhaps others, are part of the Regular Expression concept of word characters.

31.4.4. Assignment JS.Regex.3

Include the file http://dkexit.eu/downloads/17192_8.js in a web page. It is a JS file holding a string constant named text2. The constant is an annotated poem by Poe, re the C-comments of the file. Make a wordlist in an array by means of a match. How many words are in the text? Make the page print the number.

By traversing the word array make a new array that has all the different words from the first array, and a count for each of those words. Print the array on the page.

Finally the page must display a character count, What is the frequency of each letter in the alphabet. Create an object with the result as in

'use strict';
let obj = {
    a: 2.56,
    b: 0.24,
    ,,,
    z: 0.86
};

and place the results on the page.

31.4.5. Assignment JS.Regex.4

This assignment is the same as Section 31.4.4 but with http://dkexit.eu/downloads/8fdmf10.js as input. It is a JS file holding a string constant named text1. The constant is a Danish text from the late 19th century.