intel / hyperscan

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

Finding proper RE syntax or hyperscan documentation about syntax #198

Open urmel1960 opened 4 years ago

urmel1960 commented 4 years ago

Hi there

According the hyperscan website hyperscan follows the regular expression syntax of the PCRE library. The regex \N\.rocks is causing an error in rspamd which is using hyperscan.

The regex \N\.rocks is PCRE compliant according to several check in documentation: Match any single character that is NOT a line break character (line feed) «\N» Match the character “.” literally «.» Match the character string “rocks” literally (case sensitive) «rocks»

But I still get the following error with that RE: cannot create tree of regexp when processing '\\N\\.rocks': '\\N' at index 0 not supported.

Can anyone help with getting the proper syntax for this RE?

Thanks in advance

xiangwang1 commented 4 years ago

Hi @urmel1960,

\N is currently not supported by Hyperscan.

\N is not frequently used and matches anything except newline which is identical to .. The only difference is that \N ignores /s modifier. You may consider to replace it with . if possible. We will think about adding the support in next release.

Thanks, Xiang

urmel1960 commented 4 years ago

Hi @xiangwang1

Thanks for the explanation. Is there a documentation in which the syntax and its exceptions are described?

Thanks

xiangwang1 commented 4 years ago

Although it doesn't mention \N support, please check it out at http://intel.github.io/hyperscan/dev-reference/compilation.html#pattern-support.

urmel1960 commented 4 years ago

Hi @xiangwang1 May I ask an addition question related to this?

are forward slashes supported within hyperscan?

e.g. /regexpattern/

xiangwang1 commented 4 years ago

No, same as PCRE library, Hyperscan doesn't support it.

urmel1960 commented 3 years ago

Hi @xiangwang1

Meanwhile I do have another question related to hyperscan syntax.

Does hyperscan support lookbehind ?

Thanks for your support in advance