router
router copied to clipboard
Regex Support in Rhai
Is your feature request related to a problem? Please describe.
Working in Rhai is typically preferred for performance reasons when config can't suffice. For some customers, there is a need to do complex lookups on string values to ensure they match a specific format (and optionally retrieve matching values).
As a concrete example, if a customer needed to check against a User-Agent value and apply a different header based on that value, regex could be well-suited for this need since simple string lookups may not suffice when working with the format.
While it may work for some use-cases, and might be able to work for others, it creates a lot of gnarly code that regex is uniquely suited for.
Additionally, pattern matching a header value can incredibly powerful.
Describe the solution you'd like
Support for Regex in Rhai, ideally:
- A method to generate a new "regex" type from a user-provided regex string
- From that regex type, the ability to do both non-matching and matching group lookups
Describe alternatives you've considered
As noted above, using substring lookups.
Just adding my support for this, would be nice to be able to do some pattern matching against the query to support some use cases like looking for a query name by a specific pattern. (ie, same as the operation name).
We have a use case where we need to pattern match against header names in a Rhai script and regex would greatly simplify this