Doesn't rg support RegEx flags such as Ungreedy matching? #1698
-
It seems that a lazy positive lookahead is impossible, also it seems that there is no such (I guess redundant) thing, because the Ungreedy flag (make all matches lazy by default) accomplishes the task. You can see for yourself with this PCRE implementation: regex101.com
for this input:
matches upto the last dot. Adding a question mark to the syntax:
makes it match all the input. The same happens on that implementation website. BUT enabling the U flag makes |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 14 replies
-
Sorry I'm confused. What question are you asking here? Non-greedy matching is unrelated and orthogonal to look around. |
Beta Was this translation helpful? Give feedback.
-
Sorry but is this some Troll Post?
The examples show everything including how they are related to look-around.
What exactly are you confused about?
sob., 3 paź 2020 o 18:17 Andrew Gallant <notifications@github.com>
napisał(a):
… Sorry I'm confused. What question are you asking here?
Non-greedy matching is unrelated and orthogonal to look around.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1698 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOSWAAA375JUR4ZYSYA4IUTSI5FCBANCNFSM4SCXGHMA>
.
|
Beta Was this translation helpful? Give feedback.
-
Maybe all you're asking is how to use non-greedy matching. If so, I'll answer that, but your post is really confusing. If you want to use non-greedy matching, then you have two options. The first is to add a question mark to the repetition operator that you want to be non-greedy. e.g., As far as I know, this is standard across all regex engines that support greediness. |
Beta Was this translation helpful? Give feedback.
Maybe all you're asking is how to use non-greedy matching. If so, I'll answer that, but your post is really confusing.
If you want to use non-greedy matching, then you have two options. The first is to add a question mark to the repetition operator that you want to be non-greedy. e.g.,
??
,+?
and*?
are the non-greedy versions of?
,+
and*
. You can also use theU
flag to invert the greediness of all repetition operators.As far as I know, this is standard across all regex engines that support greediness.