HTML and CSS Reference
1. Write a regular expression that will:
a. Return true if a string begins with letters between a and f , either upper- or
b. Return true if a string contains a number.
c. In the string My friend is Betsy Ann Savage , capture the first and last name
and display them in reverse, as Savage, Betsy .
d. Replace Betsy with Elizabeth in the previous string.
e. In the string 123abcdefg584 , replace all the letters with XXX .
f. Prompt the user for a string of text, then print true if the string ends in three
or more numbers.
g. Prompt the user for a string of text, then display the first three characters in
h. Prompt the user for a string of text that includes letters and numbers, then
print true if the string does not contain the number 4 or the letter a , or print
false if not.
Prompt the user for his or her first and last name. Display true if the name
starts with an uppercase letter followed by lowercase letters. The last name
would be similar to the following: Jones , Smith , McFadden , O'Reilly , and
2. Validate an international phone number that is represented as follows:
011 49 762 899 20
3. Start with a one- or two-character code for a United Kingdom postal district,
such as B for Birmingham or RH for Red Hill, followed by a one- or two-digit
number to represent a sector within that district. For example, RH1 is Red Hill
district, sector 1; CM23 is the Chelmsford district, sector 23; and B1 is Birming-
ham district, sector 1. Following the district and sector is a space, followed by a
digit and two characters, such as 4GJ.
For example: CM23 2QP
CM = Chelmsford district
23 = sector 23
2QP = a particular road.
Create a regular expression to validate a UK postal code as just described.
4. Validate a credit card number using the Lunh formula.