Anchored Regex That Filters Well-Formed Requests
Short answer
D Use the anchored pattern ^https://10\.1\.2\.3/api\?id=[0-9]+$ so only fully well-formed GET requests are filtered and anomalies stay in the logs.
Question
Key Takeaways
The question tests full-string regex anchoring for log filtering; the trap is assuming a prefix match or a negative lookahead identifies a correctly formatted request.
This CS0-003 scenario tests building a regular expression that removes correctly formatted GET requests to https://10.1.2.3/api?id=<integer> from CSRF log review. The correct pattern is option D, anchored at both start and end for an exact full-string match.
Common mistake: Option A, a negative lookahead, is chosen by readers who parse 'filter out the correctly formatted requests' as 'show only bad requests' — but it has no end anchor, so URLs with extra parameters or trailing payload still begin with a valid prefix and get discarded as correct.
Expert Analysis
What the pattern has to prove
The analyst's filter exists to remove requests that are provably well-formed from the CSRF review queue, so the regex must positively identify exactly one shape: https://10.1.2.3/api plus a single integer id. That makes D (^https://10\.1\.2\.3/api\?id=[0-9]+$) correct, because ^ and $ together demand that the entire log field — not a fragment of it — is the expected URL.
Why the unanchored variants are dangerous
Option B is the classic near-miss: \d+ will happily match the leading digits of id=12<script> or id=7&redirect=evil, so a request carrying an injected extra parameter or payload is classified as correct and filtered away. Option C drops both anchors, so the pattern can match anywhere inside a longer or re-redirected URL. Both yield false negatives — malicious traffic silently leaves the queue while analysts triage noise.
The negative-lookahead trap
One line of reasoning argues that ^(?!...) is right because the question says "filter out the correctly formatted requests" and that construct "will only display wrong format." It fails technically: the lookahead tests only the prefix and has no end condition, so https://10.1.2.3/api?id=5&next=https://evil begins with a valid prefix, the lookahead refuses to match, and that request is discarded as correct — exactly the CSRF-style anomaly the filter exists to expose.
What would flip the answer
If the API accepted multiple or optional parameters, or the goal were to highlight only malformed entries rather than suppress good ones, the required pattern would change. Under the stated constraints — one integer argument, exact URL — anchoring mistakes translate directly into false negatives, which is why full-string matching is the doctrine tested here.
Official Reference
https://www.comptia.org/certifications/cybersecurity-analyst
This link opens the official vendor documentation in a new tab.
Exam Strategy
Read the required format as a checklist — scheme, host, path, parameter name, data type — then demand that the pattern covers all of it from ^ to $ before considering alternatives. When two options differ only by anchors, choose the fully anchored one for filtering tasks, because unanchored patterns create false negatives in log triage. Treat any negative-lookahead option as a distractor unless the question explicitly asks to surface only nonconforming entries, and verify it still enforces the end of the string.
Frequently Asked Questions
Why does a log-filtering regex need both ^ and $?
What happens if the analyst uses option B instead of D?
When would a negative lookahead like option A be appropriate?
Community Votes
80% of anonymous learners picked answer D. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 6 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 6
-
hashed_pony 👍 18 Answered DWho's going to memorize regex for an exam? You have to be kidding... Anyway, just memorized it start with an ^ and ends with a $ sign. -_-
-
Popeyes_Chicken 👍 5 Answered DD. ^https://10\.1\.2\.3/api\?id=[0-9]+$ Matches the URL exactly from start (^) to end ($), making sure no extra characters exist before or after the URL. It meets all the stated requirements.
-
Robuste7 👍 5 Answered DI’m taking the exam on next Sunday, I’m putting this in my memory ^…$,
-
4ee1800 👍 2 Answered D^...$ = Perfectly matches the entire string.
-
agfencer 👍 1Did anyone read the question? It's asking to filter OUT the correct ones, and only display wrong format ^(?! = does not match the regex to follow the answer is A
Show 1 more comment
-
idts0987 👍 1how did you do?
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.