observablehq / feedback

Customer submitted bugs and feature requests
42 stars 3 forks source link

Regular expression capturing groups don't work right with Replace All #412

Closed akrawitz closed 1 month ago

akrawitz commented 2 years ago

Describe the bug If you try to use a regular expression capturing group with Replace All, every instance will use the capturing group from the first instance, instead of each instance using it's own capturing group.

To Reproduce Steps to reproduce the behavior:

  1. Create a Markdown cell with the contents:
    A find
    B find
    C find
    D find
    E find
  2. Click Open find pane
  3. Click to open Settings
  4. Click to enable Regular expression setting
  5. For Find enter: ([A-Z]) find
  6. Click to open Replace
  7. For Replace enter: $1 replace
  8. Click the Replace All button
  9. The cell now contains:
    A replace
    A replace
    A replace
    A replace
    A replace

Expected behavior I expect the cell to now contain:

A replace
B replace
C replace
D replace
E replace

Desktop (please complete the following information):

Additional context Interestingly, if you click Replace Current repeatedly, instead of clicking Replace All once, then you get the expected result.