[pcre-dev] [Bug 2645] New: error when trying to substitute a…

トップ ページ
このメッセージを削除
著者: admin
日付:  
To: pcre-dev
題目: [pcre-dev] [Bug 2645] New: error when trying to substitute an optional capture group that was not matched
https://bugs.exim.org/show_bug.cgi?id=2645

            Bug ID: 2645
           Summary: error when trying to substitute an optional capture
                    group that was not matched
           Product: PCRE
           Version: 10.35 (PCRE2)
          Hardware: x86
                OS: Linux
            Status: NEW
          Severity: bug
          Priority: medium
         Component: Code
          Assignee: Philip.Hazel@???
          Reporter: planet36@???
                CC: pcre-dev@???


I reported a bug to the fish shell project about its "string replace" command.
The bug report was closed, and pcre2 was blamed as the source of the error.
Someone suggested creating a bug here.

https://github.com/fish-shell/fish-shell/issues/7343

Description:
The issue is that when trying to substitute a group that didn't match (because
it was optional), an error is given instead of substituting an empty string.

Steps to reproduce:
echo 'az' | string replace -r -- 'a(b.+)?z' 'a:$1z'
echo 'abz' | string replace -r -- 'a(b.+)?z' 'a:$1z'
echo 'abcz' | string replace -r -- 'a(b.+)?z' 'a:$1z'

Output:
string replace: Regular expression substitute error: requested value is not set
abz
a:bcz

I expected the first command to print
a:z

Here is an example that behaves as expected.
https://regex101.com/r/wG3aM3/931

--
You are receiving this mail because:
You are on the CC list for the bug.