Skip to content

Doesn't rg support RegEx flags such as Ungreedy matching? #1698

Discussion options

You must be logged in to vote

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 the U flag to invert the greediness of all repetition operators.

As far as I know, this is standard across all regex engines that support greediness.

Replies: 3 comments 14 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@BurntSushi
Comment options

Comment options

You must be logged in to vote
13 replies
@BurntSushi
Comment options

@okdana
Comment options

@StacktraceException
Comment options

@BurntSushi
Comment options

@StacktraceException
Comment options

Answer selected by BurntSushi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants