Menu

#951 Unexpected captured groups in replacements

4.3
closed-fixed
search (7)
5
2026-08-12
2019-06-08
msoutopico
No

In a search and replace operation it seems the capturing doesn't work as expected.

For example, given a segment containing a figure such as "10 000", I want to remove the space.

I search for (\d)\s(\d) and replace with $1$2.

The expected result is 10000.
The actual result is 10 00.

It seems the second capturing group is capturing the space.

1 Attachments

Discussion

  • msoutopico

    msoutopico - 2019-06-11

    It seems the issue happen when you check the "Space matches nbsp" option. But even then, not systematically.

     
  • Briac Pilpré

    Briac Pilpré - 2019-06-11

    When replacing text with the "Space matches nbsp" option checked, all the "" in the search were replaced by "( |\u00A0)". This resulted in bad capturing groups for the users.
    The space is now replaced by "(?: |\u00A0)" to avoid saving the capturing group.

    This should be fixed in [30bd7c].

     

    Related

    Commit: [30bd7c]

  • Briac Pilpré

    Briac Pilpré - 2019-06-11
    • labels: --> search
    • status: open --> open-fixed
     
  • Aaron Madlon-Kay

    • assigned_to: Briac Pilpré
    • Group: 4.2 --> 4.3
     
  • msoutopico

    msoutopico - 2019-06-28

    Thanks, Briac!

     
  • Aaron Madlon-Kay

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -8,5 +8,3 @@
     The actual result is 10 00.
    
     It seems the second capturing group is capturing the space.
    -
    -https://imgur.com/gpDLCBH
    
    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -0,0 +1 @@
    +gpDLCBH.png (49.3 kB; image/png)
    
     
  • Aaron Madlon-Kay

    Please attach screenshots directly to the ticket, rather than hosting them elsewhere. That way we will still be able to understand the issue when the external host goes out of business or breaks their URLs or someone deletes the hosted image.

     
  • Aaron Madlon-Kay

    • status: open-fixed --> closed-fixed
     
  • Aaron Madlon-Kay

    Released in 4.3.0.

     
  • Andrei Raugas

    Andrei Raugas - 2026-08-12

    The same (or similar) issue occurs again in version 6.0.1. See:
    https://sourceforge.net/p/omegat/bugs/1330/

     

Log in to post a comment.