Exercises

Regular expressions

  1. Fix the following sentences (you can chain multiple regular expressions):

    1. "This $entence is AlL oOoooOOoover the place, so its quite hard to overlook al of these spelling problems!"
    2. "Ill call a TaXi 4 u. It will cost around 4 dollars."
    3. "This sentence contains too man y s p a c e s."

Expected output:

(a): "This sentence is all over the place, so it's quite hard to overlook all of these spelling problems!"
(b): "I'll call a taxi for you. It will cost around 4 dollars."
(c): "This sentence contains too many spaces."
  1. Write a regular expression that would match all of the words in the following array:

    1. "All", "Tall", "Ball"
    2. "map", "amp", "LAMP", "Ape"

Expected output:

(a): TRUE, TRUE, TRUE
(b): TRUE, TRUE, TRUE, TRUE