Splunk Infrastructure Overview — Question 41
Which is a regex best practice?
Answer options
- A. Use complex expressions rather than simple ones.
- B. Avoid backtracking.
- C. Use greedy operators (.*) instead of non-greedy operators (.*?).
- D. Use * rather than +.
Correct answer: B
Explanation
The correct answer is B because avoiding backtracking can improve performance and prevent excessive resource consumption in regex operations. Options A and C suggest practices that can lead to inefficient regex patterns, while option D indicates a misunderstanding of quantifiers, as + is often more appropriate when at least one occurrence is required.