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

Here are three predefined character classes: \\d, \\s, and \\w. Describe each on

ID: 3570942 • Letter: H

Question

Here are three predefined character classes: d, s, and w. Describe each one, and rewrite its equivalent using the square bracket syntax.

Consider the regular expression (dog){3}. Identify the two subexpressions. What string does the expression match?

Write an expression that will match a person's name only if that person's first name and last name are the same.

Write a regular expression that matches all strings over the alphabet {a, b, c} that contain:

a)starts and ends with a      

b)at most one a                    

at least two a's

Explanation / Answer

Question: Here are three predefined character classes: d, s, and w. Describe each one, and rewrite it using square brackets.

Answer:
d    Matches any digit.    [0-9]
s    Matches any white space character.    [ -x0B ]
w    Matches any word character.    [a-zA-Z_0-9]


Question: Consider the regular expression (dog){3}. Identify the two subexpressions. What string does the expression match?

Answer: The expression consists of a capturing group, (dog), followed by a greedy quantifier {3}. It matches the string "dogdogdog".

Question: Use a backreference to write an expression that will match a person's name only if that person's first name and last name are the same.

Answer: ([A-Z][a-zA-Z]*)s

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