p-ranav / hypergrep

Recursively search directories for a regex pattern
MIT License
204 stars 7 forks source link

Use Dot All mode #15

Closed p-ranav closed 1 year ago

p-ranav commented 1 year ago

“Dot all” mode Tip Use “dot all” mode where possible.

Not using the HS_FLAG_DOTALL pattern flag can be expensive, as implicitly, it means that patterns of the form /A.B/ become /A[^\n]B/.

It is likely that scanning tasks without the DOTALL flag are better done ‘line at a time’, with the newline sequences marking the beginning and end of each block.

This will be true in most use-cases (an exception being where the DOTALL flag is off but the pattern contains either explicit newlines or constructs such as \s that implicitly match a newline character).