question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to support quantifier (n,m) for rule matching?

See original GitHub issue
! | Negate the pattern, by requiring it to match exactly 0 times.
-- | --
? | Make the pattern optional, by allowing it to match 0 or 1 times.
+ | Require the pattern to match 1 or more times.
* | Allow the pattern to match zero or mo

In addition to the operators above, is it possible to support the {n,m} quantifier in the rule matcher? Or least {n} times. The reason is that, for linear matching, there is often a need to restrict how far two tokens occur in a piece of text. The shorter the distance, the more reliable the pattern. For example:

pattern = [{"LOWER": "hello"},
           {"LOWER": "world"}] 

For this pattern, I want to add an additional condition to require that the two words ‘hello’ and ‘world’ will be within a distance of no more than 12 words. Is there a way to express this logic for the current matcher? If not, how likely this can be supported by introducing the RE quantifier {n,m}? This is very useful for pattern matching in practical applications.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
svlandegcommented, Mar 31, 2021
0reactions
github-actions[bot]commented, Jul 31, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Regex exactly n OR m times - Stack Overflow
There is no single quantifier that means "exactly m or n times". The way you are doing it is fine. An alternative is:...
Read more >
Quantifiers in Regular Expressions - Microsoft Learn
The quantities n and m are integer constants. Ordinarily, quantifiers are greedy. They cause the regular expression engine to match as many ...
Read more >
Regex Quantifier Tutorial: Greedy, Lazy, Possessive - RexEgg
It is "one or more, but as many as possible (greedy), and giving back characters if needed in order to allow the rest...
Read more >
Quantifiers +, *, ? and {n} - The Modern JavaScript Tutorial
A quantifier is appended to a character (or a character class, or a [...] set etc) and specifies how many we need. \d{5}...
Read more >
Quantifiers - JavaScript - MDN Web Docs - Mozilla
By default quantifiers like * and + are "greedy", meaning that they try to match as much of the string as possible. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found