Skip to content

mcedit search/replace: captured group reference \1 not replaced if surrounded by \{ ... \} #4742

@GfEW

Description

@GfEW

Is there an existing issue for this?

  • I have searched the existing issues

Midnight Commander version and build configuration

$ mc -V
GNU Midnight Commander 4.8.33-1
Built with GLib 2.84.0
Built with ncurses 6.5
Built with libssh2 1.11.1
With builtin editor
With subshell support as default
With support for background operations
With mouse support on xterm
With support for X11 events
With multiple codepages support
Virtual File Systems:
 cpiofs, tarfs, sfs, extfs, ftpfs, sftpfs, shell
Data types:
 char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64; uintmax_t: 64;
$ apt info mc 2>&- | grep Version
Version: 4.8.33-1

Operating system

Linux localhost 4.19.157-perf-[...]-dirty [...] SMP PREEMPT [...] aarch64 Android

Is this issue reproducible using the latest version of Midnight Commander?

  • I confirm the issue is still reproducible with the latest version of Midnight Commander

How to reproduce

capture group not replaced if surrounded by '{ ... }'

  • example line:
    echo $foo_bar
  • search pattern:
    \$(\w+)
  • replace pattern:
    \$\{\1\}

Expected behavior

  • expected result:
    echo ${foo_bar}

Actual behavior

  • actual result:
    echo ${\1}

Additional context

If the braces are not escaped, the replacement works as expected:

  • replace pattern:
    \${\1}
  • actual result:
    echo ${foo_bar}

Whilst braces in the replacement string don't need to be escaped, doing so should certainly not break captured group references.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: mceditmcedit, the built-in text editorprio: mediumHas the potential to affect progress

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions