Exam CAS-004 All QuestionsBrowse all questions from this exam
Question 468

A security analyst is reviewing a new IOC in which data is injected into an online process. The IOC shows the data injection could happen in the following ways:

• Five numerical digits followed by a dash, followed by four numerical digits; or

• Five numerical digits

When one of these IOCs is identified. the online process stops working. Which of the following regular expressions should be implemented in the NIPS?

    Correct Answer: B

    The best regular expression to address the given IOC patterns is ^\d{5}(-\d{4})?$. This regular expression precisely matches the described formats: five numerical digits followed by an optional dash and four numerical digits, or just five numerical digits alone. '^' asserts the start of the string, '\d{5}' matches exactly five digits, '(-\d{4})?' optionally matches a dash followed by exactly four digits, and '$' asserts the end of the string. This ensures that the patterns described in the IOC are properly detected.

Discussion
MacherGamingOption: B

B - ^\d{5}(-\d{4})?$: Spend a few hours on https://regex101[.]com/ if you don't already know it. ^ - position at the start of the line \d - matches any digit [0-9] {5} - matches the previous token 5 times (in this case '\d' or any digit) ( ....)? - Capture group, includes a match on the first token (our 5 digits) and what's inside the (...). -\d{4} - a dash "-" followed by any 4 digits $ - position at the end of a line