Answer by Wiktor Stribiżew for why is my regex greedy
Remember that a regex engine parses strings from left to right. You have blocks of substrings that are delimited with edit and next. Since the first edit block can be matched first, it is matched, and...
View ArticleAnswer by alseether for why is my regex greedy
Note that thisedit 1035 set schedule "always" set service "ALL2" set utm-status enablenextedit 103 set schedule "always" set service "ALL" set utm-status enablenextalso match your regex. It starts...
View ArticleAnswer by Josh Withee for why is my regex greedy
First, notice that your regex can be simplified to:(edit[\s\S]*?service ("ALL")[\s\S]*?next)Now, regarding your question - the reason it does that is because when you have the "ALL2"in the text, there...
View Articlewhy is my regex greedy
The regex in question is:(edit[\s\S]{0,}?service ("ALL")[\s\S]{0,}?next)In the following example, my regex is working properly and it finds me all matches correctly from this:edit 1035 set schedule...
View Article