Re: Regex: A case where the longest match isn't being found

2023-10-27 Thread Chet Ramey
On 10/27/23 1:04 AM, Lawrence Velázquez wrote: On Fri, Oct 27, 2023, at 12:25 AM, Grisha Levit wrote: On Thu, Oct 26, 2023, 20:30 Dale R. Worley wrote: I suspect the difference between the versions is how the regexp is unquoted while it is being read, with version 3 interpreting [^\'] as

Re: Regex: A case where the longest match isn't being found

2023-10-26 Thread Lawrence Velázquez
On Fri, Oct 27, 2023, at 12:25 AM, Grisha Levit wrote: > On Thu, Oct 26, 2023, 20:30 Dale R. Worley wrote: > >> I suspect the difference between the versions is how the regexp is >> unquoted while it is being read, with version 3 interpreting [^\'] as >> "character class excluding newline,

Re: Regex: A case where the longest match isn't being found

2023-10-26 Thread Grisha Levit
On Thu, Oct 26, 2023, 20:30 Dale R. Worley wrote: > I suspect the difference between the versions is how the regexp is > unquoted while it is being read, with version 3 interpreting [^\'] as > "character class excluding newline, backslash, and quote" and version 5 > interpreting it as "character

Re: Regex: A case where the longest match isn't being found

2023-10-26 Thread Dan Bornstein
Thanks to the folks who replied. Indeed, I misunderstood the "longest match" rule to apply to captures and not just the whole string. (That is, I thought an earlier capture would get "first dibs" on any matching text.) And, as was pointed out by Greg W, the exact behavior depends more on the

Re: Regex: A case where the longest match isn't being found

2023-10-26 Thread Lawrence Velázquez
On Thu, Oct 26, 2023, at 7:01 PM, Greg Wooledge wrote: > On Thu, Oct 26, 2023 at 10:50:13AM -0700, Dan Bornstein wrote: >> I found a case where the regex evaluator doesn't seem to be finding the >> longest possible match for a given expression. The expression works as >> expected on an older

Re: Regex: A case where the longest match isn't being found

2023-10-26 Thread Dale R. Worley
"Dan Bornstein" writes: > I found a case where the regex evaluator doesn't seem to be finding > the longest possible match for a given expression. The expression > works as expected on an older version of Bash (3.2.57(1)-release > (arm64-apple-darwin22)). > > Here's the regex:

Re: Regex: A case where the longest match isn't being found

2023-10-26 Thread Greg Wooledge
On Thu, Oct 26, 2023 at 10:50:13AM -0700, Dan Bornstein wrote: > I found a case where the regex evaluator doesn't seem to be finding the > longest possible match for a given expression. The expression works as > expected on an older version of Bash (3.2.57(1)-release > (arm64-apple-darwin22)).