ExamGecko
Question list
Search
Search

Question 57 - SPLK-1004 discussion

Report
Export

Which is a regex best practice?

A.
Use complex expressions rather than simple ones.
Answers
A.
Use complex expressions rather than simple ones.
B.
Avoid backtracking.
Answers
B.
Avoid backtracking.
C.
Use greedy operators (. *) instead of non-greedy operators (. *? ).
Answers
C.
Use greedy operators (. *) instead of non-greedy operators (. *? ).
D.
Use * rather than +.
Answers
D.
Use * rather than +.
Suggested answer: B

Explanation:

In regex (regular expressions), one of the best practices is to avoid backtracking when possible. Backtracking occurs when the regex engine revisits previous parts of the input string to attempt different permutations of the pattern, which can significantly degrade performance, especially with complex patterns on large inputs. Designing regex patterns to minimize or avoid backtracking can lead to more efficient and faster evaluations.

asked 23/09/2024
Baran Kilic
34 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first