You can optimize regular expressions to improve the collection performance.
We recommend that you refer to the following rules when you optimize regular expressions:
Use precise characters
Do not use
*
to match fields. This expression leaves space for searching, and mismatch errors may occur. For example, if you want to extract a field that consists of only letters, use[A-Za-z]
.Use appropriate quantifiers
Do not use
+
or*
. For example, if you want to use\d
to match IP addresses, use\d{1,3}
, which is more efficient.Debug a regular expression multiple times
Debugging is similar to troubleshooting. You can debug your regular expression at the regex101 website to reduce the time required for matching. If a large number of backtraces are found, you can optimize your regular expression at the earliest opportunity.