Regex find/replace in Trados 2015
Thread poster: Samuel Murray

Samuel Murray  Identity Verified
Netherlands
Local time: 06:56
Member (2006)
English to Afrikaans
+ ...
Jan 25, 2016

Hello everyone

Is it possible in Trados 2015 to use regex replace to add some text (e.g. !!") in front of and to the end of each segment? In other words, what is the regex syntax for "start of segment" and "end of segment"?

Here's what I tried:

FIND: ^(.+)$
REPLACE: !!$1!!

SEGMENT: "<tag>" on page <tag>
(the <tag> is an actual tag in Trados, i.e. purple text)

The blog post here lead me to expect that ^ marks the start of the segment and $ marks the end of it, so I expected the above find/replace to result in this:

!!"<tag>" on page <tag>!!

Alas, it results in this:

!!"" on page !!<tag>

In other words, (1) it only selects up to the last bit of non-tag text in the segment, and (2) if the selection contains a tag, it removes the tag in the replacement.

What would the correct syntax be for what I'm looking for?

Thanks
Samuel


[Edited at 2016-01-25 16:02 GMT]


Direct link Reply with quote
 

Dan Lucas  Identity Verified
United Kingdom
Local time: 05:56
Member (2014)
Japanese to English
Quirk of Studio regex implementation? Jan 25, 2016

Samuel Murray wrote:
In other words, (1) it only selects up to the last bit of non-tag text in the segment, and (2) if the selection contains a tag, it removes the tag in the replacement.
What would the correct syntax be for what I'm looking for?

Can't help myself Samuel, other than to confirm that as a C#-style (.NET) regex your regex seems to work fine on raw text. So it's a Studio issue. Interesting, if annoying.

Dan


Direct link Reply with quote
 

SDL Community  Identity Verified
United Kingdom
Local time: 06:56
English
Could only be done... Jan 25, 2016

Samuel Murray wrote:

What would the correct syntax be for what I'm looking for?



... directly on the sdlxliff as you need to look for text. Regex only works on text.

Regards

Paul
SDL Community Support


Direct link Reply with quote
 

Samuel Murray  Identity Verified
Netherlands
Local time: 06:56
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
Thanks, Paul, for confirming it Jan 25, 2016

SDL Community wrote:
Samuel Murray wrote:
What would the correct syntax be for what I'm looking for?

Could only be done... directly on the sdlxliff as you need to look for text. Regex only works on text.


While it's true that regex only works on text, there is no programmatic reason why Trados could not support this: all it has to do, is let the find/replace dialog treat the segment not as-is but as "text in which tags are temporarily treated as textual elements".


Direct link Reply with quote
 

Stepan Konev  Identity Verified
Russian Federation
Local time: 08:56
English to Russian
Additional question Jan 26, 2016

Recently, I was fiddling with regex search and replace function and found out that the replacement operation cannot be undone.

I replaced ANGLEBRACKETanytextANGLEBRACKET to empty vavue.
First, 'Replace _all_' did not work for _all_ instances. I had to ckick 'Replace all' five times before it reached the end of document.
Second, I could not undo this operation because the undo command was inactive (grayed out).

Can anybody confirm?

[Edited at 2016-01-26 06:17 GMT]


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 find/replace in Trados 2015

Advanced search







SDL Trados Studio 2017 only €415 / $495
Get the cheapest prices for SDL Trados Studio 2017 on ProZ.com

Join this translator’s group buy brought to you by ProZ.com and buy SDL Trados Studio 2017 Freelance for only €415 / $495 / £325 / ¥60,000 You will also receive FREE access to our getting started eLearning program!

More info »
Protemos translation business management system
Create your account in minutes, and start working! 3-month trial for agencies, and free for freelancers!

The system lets you keep client/vendor database, with contacts and rates, manage projects and assign jobs to vendors, issue invoices, track payments, store and manage project files, generate business reports on turnover profit per client/manager etc.

More info »



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