Issues with Using Regex in the Search and Replace Function

I am trying to search ‘ (’ and replace it to ‘(’.


1. I get a regular expression related error while using the Search and Replace function, even though the Use regular expressions option is unchecked.
The same problem occurs even after closing and restarting Trados.

Search and Replace dialog box with an error icon next to the 'Use regular expressions' option, which is unchecked.

2. When I tick the Use regular expressions option and then try to find ‘\s\(’ and replace it with ‘\(’, it does it with ‘\(’ instead of ‘(’.
So I try to find ‘\s(\()’ and replace it to ‘\1’, I get an error saying that ‘\1’ is not a valid regular expression.

Search and Replace dialog box showing the 'Use regular expressions' option checked with a warning icon next to it.

Could anybody help with this problem? Thank you so much in advance.



Generated Image Alt-Text
[edited by: RWS Community AI at 5:02 AM (GMT 0) on 21 Nov 2024]
emoji
Parents Reply
  •    

    It’s an old bug, isn’t it  ?

    Yes... our reference CRQ-10543.  It's such a rare thing it's never made it to a fix.  The main reason it's rare is that this only occurs if you specifically check the regex checkbox first and then uncheck it.  If you didn't do this it works OK.  And of course using regex is an easy workaround.  So never made it to be prioritised over other things.

    Having demonstrated that the Replace with field uses regular expressions, it won’t handle properly the pattern “$1 \(”, while “$1 (” will be handled as a hybrid pattern (a backreference followed by a non-regex pattern), which puzzles me… ?

    Probably because using any regex apart from a back reference in the replace field would be incorrect.  The replacement only uses literal text.  So I would expect this:

    $1 \(

    To replace with the captured back reference followed by a space and the literal characters \(.  Which does work.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

    emoji
Children
No Data