Search Header Logo

SQL Regular Expressions Quiz

Authored by Dinesh Kumar

Other

Professional Development

Used 1+ times

SQL Regular Expressions Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

What does REGEXP_LIKE(CustomerID, '^A') check?

CustomerID ends with 'A'

CustomerID contains 'A'

CustomerID starts with 'A'

Invalid syntax

Answer explanation

REGEXP_LIKE(CustomerID, '^A') checks if CustomerID starts with 'A'. The caret (^) indicates the start of the string, making 'CustomerID starts with 'A'' the correct choice.

2.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

What does REGEXP_INSTR(Manager, '[aeiou]') return?

Count of vowels

Position of first vowel

TRUE/FALSE

Replaces vowels

Answer explanation

REGEXP_INSTR returns the position of the first occurrence of a pattern in a string. In this case, it finds the position of the first vowel in 'Manager', making 'Position of first vowel' the correct answer.

3.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

What does this return: REGEXP_COUNT('Hello123', '[0-9]')?

0

3

1

NULL

Answer explanation

The function REGEXP_COUNT counts the number of matches for the regex '[0-9]' in the string 'Hello123'. There are three digits (1, 2, and 3), so it returns 3, making '3' the correct answer.

4.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

Which function extracts a substring using a regex pattern?

REGEXP_REPLACE

SUBSTRING

REGEXP_SUBSTR

INSTR

Answer explanation

The function REGEXP_SUBSTR is specifically designed to extract substrings that match a given regex pattern, making it the correct choice. Other options like REGEXP_REPLACE and INSTR serve different purposes.

5.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

What does REGEXP_REPLACE(CustomerID, '[^A-Za-z]', '') do?

Replaces alphabetic characters

Removes all letters

Keeps only letters

Replaces NULL values

Answer explanation

REGEXP_REPLACE(CustomerID, '[^A-Za-z]', '') removes all non-alphabetic characters, effectively keeping only the letters. Therefore, the correct answer is 'Keeps only letters'.

6.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

What is returned by REGEXP_LIKE('R-1001', '^[A-Z]-\d{4}$')?

TRUE

FALSE

Error

1001

Answer explanation

REGEXP_LIKE checks if 'R-1001' matches the pattern '^[A-Z]-\d{4}$'. The pattern requires a single uppercase letter, a hyphen, and exactly four digits. 'R-1001' meets these criteria, so it returns TRUE.

7.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

What does [[:digit:]] represent?

Alphabetic characters

Letters and digits

Digits (0–9)

Punctuation

Answer explanation

The notation [[:digit:]] is a regular expression that specifically matches any digit from 0 to 9. Therefore, the correct answer is 'Digits (0–9)', as it accurately describes what this expression represents.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?