intel / hyperscan

High-performance regular expression matching library
https://www.hyperscan.io
Other
4.8k stars 715 forks source link

Pattern matching stop after first match on a line #337

Closed ituronova closed 2 years ago

ituronova commented 2 years ago

I am using a script: https://github.com/intel/hyperscan/blob/master/examples/simplegrep.c to match a regular expression in an input text.

I would like to search each line of the input text, however, I want stop searching in a line after the first match occurs. I would like to get a number of lines with a match as soon as possible.

It is possible to somehow modify the script to do so?

Thank you.

hongyang7 commented 2 years ago

You can try HS_FLAG_SINGLEMATCH for your rule, just refer to this link Pattern flags