A data analyst is working with a 'ProductNotes' text field in a sales database. This field contains user-entered notes and a product's Stock Keeping Unit (SKU). The SKUs are not in a separate, structured column. The SKU has a consistent format: it always starts with "SKU:", followed by exactly three uppercase letters, a hyphen, and five digits (e.g., 'SKU:ABC-12345'). The goal is to extract only the SKU identifier (e.g., 'ABC-12345') into a new column. Which of the following regular expressions should the analyst use to capture just the SKU identifier?
The correct regular expression is SKU:([A-Z]{3}-\d{5}). The parentheses () create a 'capturing group.' This tells the regex engine to match the entire pattern but to specifically capture and return only the portion of the string that matches the pattern inside the parentheses. In this case, it matches 'SKU:' but only captures the [A-Z]{3}-\d{5} part.
(SKU:[A-Z]{3}-\d{5}) is incorrect because the capturing group includes the 'SKU:' prefix, which the requirement states should be excluded from the final extracted value.
SKU:[A-Z]{3}-\d{5} is incorrect because it will find and match the pattern, but it lacks a capturing group (), so it will not isolate and extract only the identifier part.
SKU:([A-z]{3}-\d{5}) is incorrect because the character range [A-z] is a common mistake. In ASCII, this range includes non-alphabetic characters that fall between 'Z' and 'a' (such as '[', '', ']', '^', '_', ''). The requirement specifies only uppercase letters, for which [A-Z]` is the correct and precise range.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does a 'capturing group' in regex do?
Open an interactive chat with Bash
Why is `[A-Z]` preferred over `[A-z]` in regex?
Open an interactive chat with Bash
What happens if a regex pattern doesn't have a capturing group?
Open an interactive chat with Bash
CompTIA Data+ DA0-002 (V2)
Data Acquisition and Preparation
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99 $11.99
$11.99/mo
Billed monthly, Cancel any time.
$19.99 after promotion ends
3 Month Pass
$44.99 $26.99
$8.99/mo
One time purchase of $26.99, Does not auto-renew.
$44.99 after promotion ends
Save $18!
MOST POPULAR
Annual Pass
$119.99 $71.99
$5.99/mo
One time purchase of $71.99, Does not auto-renew.
$119.99 after promotion ends
Save $48!
BEST DEAL
Lifetime Pass
$189.99 $113.99
One time purchase, Good for life.
Save $76!
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .