Regex F/R question, Trados 2015
Thread poster: Samuel Murray

Samuel Murray  Identity Verified
Netherlands
Local time: 14:47
Member (2006)
English to Afrikaans
+ ...
Dec 5, 2016

Hello

I'm trying to perform the following regex find/replace operation in Trados 2015:

find replace image

The idea is to put square brackets at the start and end of each segment. This works almost, but there are some issues that I hope can be resolved.

1. The F/R operation skips every second segment. Is there any way I can force it to process every segment?

2. Sometimes, the F/R operation stops at a segment and tells me "Segment start/end cannot be deleted". I have not been able to figure out what kinds of segments cause this (sometimes the segment is very short, sometimes quite long). Do you know what causes this and how this can be prevented?

3. I've noticed that even though I specify the start and end of the segment, if a segment starts or ends with a tag, then the brackets get added after the starting tag and before the ending tag, instead of before the starting tag and after the ending tag. Is there any way I can get Trados to perform the replacement at the *real* start and end of the segment?

Thanks
Samuel


Direct link Reply with quote
 

Nora Diaz  Identity Verified
Mexico
Local time: 06:47
Member (2002)
English to Spanish
+ ...
No answers but a question Dec 5, 2016

Hi Samuel,

I'm afraid I don't have an answer to your questions, although for #3 I think tags are always ignored so you may need an alternative solution there, such as doing the replacement manually or perhaps an Autohotkey script to move the cursor to the left before doing the replacement.

I was just curious and thought I'd ask: why do you use 3 capturing groups in your Find syntax? Wouldn't the second capturing group by itself have the same effect as using all 3?

For the segment skipping, I think that should be reported to Support. I tried your example and also saw some segment skipping with no clear pattern, so that's very odd.

Overall, I would suggest posting also in the SDL Community, but I would also suggest that if you need to add brackets to every segment in your file, you may find it easier to do so with an Autohotkey script, something like this:

Send ^{PgUp}
Send [[
Send ^{PgDn}
Send ]]
Send {Down}

You could add a loop to run it multiple times as needed.

Edited to add:
Here's the full script with a variable loop, triggered with the left Windows key:

#IfWinActive ahk_exe SDLTradosStudio.exe

Lwin::
InputBox,Var,Add brackets, How many segments would you like to add brackets to?
loop, % Var
{
Send ^{PgUp}
Send [[
Send ^{PgDn}
Send ]]
Send {Down}
}
Return



[Edited at 2016-12-05 15:28 GMT]


Direct link Reply with quote
 

Samuel Murray  Identity Verified
Netherlands
Local time: 14:47
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
@Norah Dec 5, 2016

Nora Diaz wrote:
I was just curious and thought I'd ask: why do you use 3 capturing groups in your Find syntax? Wouldn't the second capturing group by itself have the same effect as using all 3?


I suppose the expression was just a result of my thinking: "replace the first character with [[ plus the first character, replace the last character with the first character plus ]], and retain everything inbetween". I did not stop and try to make the expression simpler once I wrote it. I suppose I could simply have used ^(.*)$, right?

I tried your example and also saw some segment skipping with no clear pattern, so that's very odd.


Segment skipping would make sense if Trados regards the end of one segment to be the beginning of the next segment. In other words, "start" and "end" of segment is not a condition but a character. The same thing happens when you try to perform a wild card search in Word like ^l*^l -- it acts on every second line because the end of one line (in MS Word, the line-feed character) is also the start of the next line.

You may find it easier to do so with an Autohotkey script, something like this...


I do have such a script in AutoIt, actually, but the problem is that the bigger the SDXLIFF file, the slower Trados becomes as you move down further in the file, and that leads to (a) insertion errors and (b) just generally a very long wait. Also with the AutoIt script, the brackets actually do get inserted at the very start and end of the segment, regardless of the presence of tags.

Another relatively fast method is to use bilingual review and add the brackets to the target segments in DOCX. However, bilingual review can't export filtered segments, so if you want to perform this action on selected segments only, then the bilingual review option isn't really an option.

And Trados 2015 does not have a pseudo-translation option that retains the existing segment content.

Samuel


[Edited at 2016-12-05 15:55 GMT]


Direct link Reply with quote
 

Nora Diaz  Identity Verified
Mexico
Local time: 06:47
Member (2002)
English to Spanish
+ ...
Find/Replace Dec 5, 2016

Samuel Murray wrote:

I suppose the expression was just a result of my thinking: "replace the first character with [[ plus the first character, replace the last character with the first character plus ]], and retain everything inbetween". I did not stop and try to make the expression simpler once I wrote it. I suppose I could simply have used ^(.*)$, right?


I see what you mean now, and I think that would make sense for two separate Find and Replace operations, so one where you search for the first character and replace it with [[ plus the first character, then another one where you search for the last character and replace it with the last character plus ]].

So that would be:
Find ^(.)
Replace [[$1

Find (.)$
Replace $1]]

For the entire segment, you could simply use one capturing group for the whole thing, (.*) then replace with the added brackets before and after the backreference.

Find (.*)
Replace [[$1]]

But this doesn't solve your original problems, of course.


Direct link Reply with quote
 

Samuel Murray  Identity Verified
Netherlands
Local time: 14:47
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
@Norah Dec 5, 2016

Nora Diaz wrote:
I see what you mean now, and I think that would make sense for two separate Find and Replace operations, so one where you search for the first character and replace it with [[ plus the first character, then another one where you search for the last character and replace it with the last character plus ]].


I actually tried that, but only the first step works. I can't get Trados to add ]] (or }}) to the end of segments.

Oh, and one can't use just "[" or "[[" in the replace field with regex enabled -- it's an invalid replacement pattern. You can use "\[\[", but that adds literally "\[\[" instead of "[[". One can use "{{" in the replace field, though.

But this doesn't solve your original problems, of course.


It would solve more than half of them.


Direct link Reply with quote
 

Nora Diaz  Identity Verified
Mexico
Local time: 06:47
Member (2002)
English to Spanish
+ ...
... Dec 5, 2016

Samuel Murray wrote:


I actually tried that, but only the first step works. I can't get Trados to add ]] (or }}) to the end of segments.

Oh, and one can't use just "[" or "[[" in the replace field with regex enabled -- it's an invalid replacement pattern. You can use "\[\[", but that adds literally "\[\[" instead of "[[". One can use "{{" in the replace field, though.



Mmm, you're right, very strange!


Direct link Reply with quote
 
FarkasAndras
Local time: 14:47
English to Hungarian
+ ...
oh boy Dec 5, 2016

Samuel Murray wrote:

Nora Diaz wrote:
I see what you mean now, and I think that would make sense for two separate Find and Replace operations, so one where you search for the first character and replace it with [[ plus the first character, then another one where you search for the last character and replace it with the last character plus ]].


I actually tried that, but only the first step works. I can't get Trados to add ]] (or }}) to the end of segments.

Oh, and one can't use just "[" or "[[" in the replace field with regex enabled -- it's an invalid replacement pattern. You can use "\[\[", but that adds literally "\[\[" instead of "[[". One can use "{{" in the replace field, though.

But this doesn't solve your original problems, of course.


It would solve more than half of them.


Unfortunately the regex engine in studio is badly broken. As you found , it won't process [ in the replace with field, neither on its own, nor with an escaping \. That's clearly a bug. Also, it should allow you to simply search for ^ and replace it with [[. Normally replacing the ^ or $ mark with something adds to the beginning/end of the string but this doesn't work in Studio either. If I just enter ^ into the search box it matches every character in the text (but it won't execute any replacements). Also, after trying some of these "odd" operations Studio threw in the towel completely, and no regex searches work now. If I search for (.*) it finds no hits even though this pattern matches literally every string ever written. If I write \1 into the replace box it complains that there is no capturing group in the search box even though there is one.
SDL support, has this been fixed in 2017? Do the developers know of the bugs?


Direct link Reply with quote
 

Nora Diaz  Identity Verified
Mexico
Local time: 06:47
Member (2002)
English to Spanish
+ ...
Same thing in Studio 2017 Dec 5, 2016

FarkasAndras wrote:

Samuel Murray wrote:

Nora Diaz wrote:
I see what you mean now, and I think that would make sense for two separate Find and Replace operations, so one where you search for the first character and replace it with [[ plus the first character, then another one where you search for the last character and replace it with the last character plus ]].


I actually tried that, but only the first step works. I can't get Trados to add ]] (or }}) to the end of segments.

Oh, and one can't use just "[" or "[[" in the replace field with regex enabled -- it's an invalid replacement pattern. You can use "\[\[", but that adds literally "\[\[" instead of "[[". One can use "{{" in the replace field, though.

But this doesn't solve your original problems, of course.


It would solve more than half of them.


Unfortunately the regex engine in studio is badly broken. As you found , it won't process [ in the replace with field, neither on its own, nor with an escaping \. That's clearly a bug. Also, it should allow you to simply search for ^ and replace it with [
lly replacing the ^ or $ mark with something adds to the beginning/end of the string but this doesn't work in Studio either. If I just enter ^ into the search box it matches every character in the text (but it won't execute any replacements). Also, after trying some of these "odd" operations Studio threw in the towel completely, and no regex searches work now. If I search for (.*) it finds no hits even though this pattern matches literally every string ever written. If I write \1 into the replace box it complains that there is no capturing group in the search box even though there is one.
SDL support, has this been fixed in 2017? Do the developers know of the bugs? [/quote]

Farkas,

I confirm all of your findings in Studio 2017, and even searching for ^(.) won't limit the search to the first character of the segment, it keeps highlighting the next character. A question: for the replacement box, should \1 do the same as $1?

In any case, I think this needs to be reported to Support, or at the very least discussed in the SDL Community, as it doesn't seem like SDL is monitoring this forum as much anymore.


Direct link Reply with quote
 

Samuel Murray  Identity Verified
Netherlands
Local time: 14:47
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
Same here Dec 5, 2016

FarkasAndras wrote:
If I just enter ^ into the search box it matches every character in the text (but it won't execute any replacements).


Yes, I've had similar results. For some reason, it matches every character.

Also, after trying some of these "odd" operations Studio threw in the towel completely, and no regex searches work now.


Same thing happened to me. I had to use a task killer to kill Trados 2015, and then restart Trados.


Direct link Reply with quote
 

Nora Diaz  Identity Verified
Mexico
Local time: 06:47
Member (2002)
English to Spanish
+ ...
SDL Community thread Dec 5, 2016

I've started a thread in the SDL Community about this issue (https://community.sdl.com/solutions/language/translationproductivity/f/90/t/9648)

Direct link Reply with quote
 

Nora Diaz  Identity Verified
Mexico
Local time: 06:47
Member (2002)
English to Spanish
+ ...
Addressed in the SDLXLIFF Toolkit Jan 14

I thought you'd like to know that the issues reported in this thread have been addressed in the latest release of the SDLXLIFF Toolkit, as reported by Paul Filkin here: https://multifarious.filkin.com/2017/01/14/revisiting-the-toolkit/

Direct link Reply with quote
 

Samuel Murray  Identity Verified
Netherlands
Local time: 14:47
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
@Nora Jan 14

Nora Diaz wrote:
I thought you'd like to know that the issues reported in this thread have been addressed in the latest release of the SDLXLIFF Toolkit, as reported by Paul Filkin here: https://multifarious.filkin.com/2017/01/14/revisiting-the-toolkit/


Good to know.

* SDLXLIFF Toolkit 1.1.37 is only available if you own Trados 2014/15
* SDLXLIFF Toolkit 2.7 (which is the one you're referring to) is only available if you own Trados 2017

How does the toolkit work, though? Do you have to have Trados 2017 installed on the computer to be able to use SDLXLIFF Toolkit 2.7? I mean, can I use it on a computer of mine that doesn't have Trados 2017 installed on it?


Direct link Reply with quote
 
FarkasAndras
Local time: 14:47
English to Hungarian
+ ...
What about studio? Jan 14

It's good that they're doing something about this, but surely the real solution would be to fix studio itself. Hopefully that's coming too.

Direct link Reply with quote
 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

Regex F/R question, Trados 2015

Advanced search







Déjà Vu X3
Try it, Love it

Find out why Déjà Vu is today the most flexible, customizable and user-friendly tool on the market. See the brand new features in action: *Completely redesigned user interface *Live Preview *Inline spell checking *Inline

More info »
WordFinder
The words you want Anywhere, Anytime

WordFinder is the market's fastest and easiest way of finding the right word, term, translation or synonym in one or more dictionaries. In our assortment you can choose among more than 120 dictionaries in 15 languages from leading publishers.

More info »



Forums
  • All of ProZ.com
  • Term search
  • Jobs
  • Forums
  • Multiple search