Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Build a pattern for the word “license”, even if it is misspelled by mixing up th

ID: 3699622 • Letter: B

Question

Build a pattern for the word “license”, even if it is misspelled by mixing up the “c” and the “s”

Define a pattern to find the number 21 followed by a single lower- or uppercase letter

Define a pattern to find two uppercase letters in a row, followed by a single digit, followed by one lowercase letter

Build a pattern to find a number from 3 to 7:

An uppercase “X”, followed by any two digits

Letter X not followed by “a” or “o”:

At least one non-alphabetic character

Letter “H” followed by any letter from “a” to “z”

A single upper- or lowercase followed by a single digit, followed by a lowercase letter

Build a pattern to a Canadian postal code. These codes have the format “letter number letter space number letter number”, where all the letters are uppercase, for example, M5P 3G4

Define a pattern to find Uppercase letter “H” followed by zero or more lowercase letters

Define a pattern to “error” followed by zero or more characters, followed by “code”

Build a pattern to find a colon, followed by zero or more occurrences of any other characters, followed by another colon

Build a pattern to find the letters “variable” followed by one or more numbers

Build a pattern to match either an uppercase “V” or lowercase “v” at the beginning of the above pattern

Word “color” (American spelling) or “colour” (British spelling)

Match exactly 3 digits

Match at least 3 digits

Match 5 or fewer digits

Match 3 to 5 digits

Match any of the following words: cat, dog, bird, hamster

Match any of the following complete words: cat, dog, bird, hamster

Consider the lines below:

But remember to use these 3 digits: 76 2

There could be an error in 32variable3x

You can concatenate as well

Remember that errorcode 541 means “Too many parentheses”

That’s your licence to kill harlly

I know you like Harmonica, even your dog

We’ll now set Variable417

Build a pattern to find either 2- or 3-digit numbers

Write a regular expression that matches against hyphenated Social Security numbers.

Write a regular expression that matches URIs. Look at the IETF document RFC 3986 for the URIs generic syntax. You cannot use the regex it defines. Please illustrate your regex with some examples

Explanation / Answer

Solution

1Q.Build a pattern for the word “license”, even if it is misspelled by mixing up the “c” and the “s”

Ans:pattern="li[cs]en[cs]e";

2Q.Define a pattern to find the number 21 followed by a single lower- or uppercase letter

Ans:pattern="21[a-zA-Z]";

3Q.Define a pattern to find two uppercase letters in a row, followed by a single digit, followed by one lowercase letter

Ans:pattern="[A-Z]{2}[0-9][a-z]";

4Q.Build a pattern to find a number from 3 to 7:

Ans:pattern="[3-7]";

5Q.An uppercase “X”, followed by any two digits

Ans:pattern="X[0-9]{2}";

6Q.Letter X not followed by “a” or “o”:

Ans:pattern="X[^ac]";

7Q.Letter “H” followed by any letter from “a” to “z”

Ans:pattern="H[a-z]";

8Q.A single upper- or lowercase followed by a single digit, followed by a lowercase letter

Ans:pattern="[a-zA-Z][0-9][a-z]";

9Q.Build a pattern to a Canadian postal code. These codes have the format “letter number letter space number letter number”, where all the letters are uppercase, for example, M5P 3G4

Ans:pattern="[A-Z][0-9][A-Z]s[0-9][A-Z][0-9]";

10Q.Define a pattern to find Uppercase letter “H” followed by zero or more lowercase letters

Ans:pattern="H[a-z]*";

11Q.Define a pattern to “error” followed by zero or more characters, followed by “code”

Ans:pattern="error.*code";

12Q.Build a pattern to find a colon, followed by zero or more occurrences of any other characters, followed by another colon

Ans:pattern=";.*;";

13Q.Build a pattern to find the letters “variable” followed by one or more numbers

Ans:pattern="variable[0-9]+";

14Q.Build a pattern to match either an uppercase “V” or lowercase “v” at the beginning of the above pattern

Ans:pattern="^{[a-z]|[A-Z]}";

15Q.Word “color” (American spelling) or “colour” (British spelling)

Ans:pattern=" colou?r";

16Q.Match exactly 3 digits

Ans:pattern="[0-9]{3}";

17Q.Match at least 3 digits

Ans:pattern="[0-9]{3,}"

18Q.Match 5 or fewer digits

Ans:pattern="[0-9]{0,5}";

19Q.Match 3 to 5 digits

Ans:pattern="[0-9]{3,5}";

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote