Question: Regex Practical 1 Exercise 1. Do a search-and-replace regex to remove whitespace (spaces and tabs) from the start and/or the end of the lines in


Regex Practical 1 Exercise 1. Do a search-and-replace regex to remove whitespace (spaces and tabs) from the start and/or the end of the lines in a text file. Exercise 2. Write a regular expression to match the various forms of the word color (US English) and colour (British English). They include the following: color, colour, colors, colours, color's, colour's, colors' and colours Exercise 3. Canadian postcodes take the form A1A 1A1, with an alphabetic character preceding a numeric digit, which in turn is followed by an alphabetic character. That in turn is followed by an optional space character, which is followed by one numeric digit, followed by one alphabetic character, followed by a numeric digit. Considering the sample file below, write a regular expression to only match valid Canadian postcodes (highlighted in grey) T3Z 3N7 D8R 804 RR4 880 P9C 304 V2X 3RU VSR854 M8N 7LK JIM604 S18 2R9 88B U20 D7R 7L2 F9Z6G4 followed by a numeric digit. Considering the sample file below, write a regular expression to only match valid Canadian postcodes (highlighted in grey) T3Z 3N7 DER 804 RR4 880 P9C 304 V2X 3RU VSR854 MSN 7LK 31M604 51B 2R9 88B U21 DZR 72 E9Z6GA Exercise 4 Do a search and replace regex to delete, from a text file, all lines containing the words "Isaac or Toto" in all the possible cases Exercise 5. Write a regular expression to match the following number ranges: a) 0-999 b) O or 00 - 59 c) 0-53 Exercise 6. Write a regular expression to match the below numbers. You have to deal with positive and negative numbers, significant digits, exponents and even different representations. 3.14529 -255.34 128 1.9e 10 123,340.00
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
