Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the substring when matched a rule? #64

Closed
landataosong opened this issue Jul 28, 2017 · 1 comment
Closed

How to get the substring when matched a rule? #64

landataosong opened this issue Jul 28, 2017 · 1 comment

Comments

@landataosong
Copy link

First, could I ask the question here?

Second, for input text "Host: www.google.com/mail", matched the rule "Host: (.*)/mail" , and I want to get the substring "www.google.com".
I think ptr + strlen("Host: ") is not a good idea, and I don't know how long for the target "www.google.com" in fact.

Thanks!

@jviiret
Copy link
Contributor

jviiret commented Jul 31, 2017

Hi there,

Questions here (or on the mailing list) are fine!

What you're asking for is capturing group support, which Hyperscan does not support. Hyperscan will only provide the end-offset of a match, or both the start- and end-offsets if you use the HS_FLAG_SOM_LEFTMOST flag.

Probably the best way to do what you're trying to do with Hyperscan is to perform some further processing in the match callback when Hyperscan finds a match. Depending on how stylized your patterns are, you could use some sort of string matching (as you've suggested), or a single-regex matcher that supports capturing groups, like PCRE, to extract the sub-match data you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants