Question: Which pattern match the following regular expressions. -Java ab*c This will match a, followed by zero or more b, followed by c. ab+c This will

Which pattern match the following regular expressions. -Java

ab*c

This will match a, followed by zero or more b, followed by c.

ab+c

This will match a followed by one or more b, followed by c.

ab?c

This will match a followed by zero or one b, followed by c. Thus, it will match both abc or ac.

ab{1,3}c

This will match a, followed by one to three occurrences of b, followed by c. Thus, it will match following strings: abc, abbc, and abbbc.

red|blue

This will match either the string red or the string blue.

[0-9]

This is a character class with a character range. The preceding example will match a digit between 0 and 9.

[a-zA-Z0-9]

This is a character class with a character range. The preceding example will match any alpha-numeric character.

-Which regex pattern should be used to match a two-digit year or a four-digit year? \d{2}|\d{4}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!