Help with Regex Match AutoSuggest Provider for SDL Trados Studio 2015
Thread poster: Fredrik Pettersson

Fredrik Pettersson  Identity Verified
Hong Kong
Member (2009)
English to Swedish
+ ...
Jul 12

The patterns I am trying to find are these:

\d+\,\d+\,\d+
Replace commas in 1,000,000 with blank spaces:
\d+\u0020\d+\u0020\d+

\d+\,\d+
Replace comma in 100,000; 10,000 and 1,000 with blank space:
\d+\u0020\d+

\d+\.\d+
Replace period with comma for numbers:
\d+\,\d+

But I can't get it to work. How should I change the Regex formulas?


Direct link Reply with quote
 

Darius Sciuka  Identity Verified
Lithuania
Local time: 14:18
Member (2016)
English to Lithuanian
+ ...
The way to go Jul 12

Hi Fredrik,

Use this one:

Regex pattern: (\d+)\,(\d+)\,(\d+)
Replace pattern: $1 $2 $3 (paste actual non-breaking space characters between $1, $2, and $3, Regex Match AutoSuggest Provider has no problem with it).
Here $1 is the string of digits found by the partial expression within the first pair of brackets, $2 - the second pair, etc.

The remaining expressions can be constructed in the same way.

HTH,
Darius


Direct link Reply with quote
 

Fredrik Pettersson  Identity Verified
Hong Kong
Member (2009)
English to Swedish
+ ...
TOPIC STARTER
How do I paste non-breaking space? Jul 12

Hi Darius,

I'm not sure if I got the third replace pattern right, did you mean this?:

(\d+)\.(\d+)
$1 \, $2

So that I get a comma instead of a period as decimal separator.

Then I tried with ALT 0160, but did you mean I should press that key sequence while in the Regex editor?


Direct link Reply with quote
 

Darius Sciuka  Identity Verified
Lithuania
Local time: 14:18
Member (2016)
English to Lithuanian
+ ...
The third pattern Jul 12

You got it almost right. If you need to replace a dot with a comma you should use the following pattern:

(\d+)\.(\d+)
$1,$2

No \ character should be used to escape any special characters in the replace pattern. You also should only insert any spaces (regular or non-breaking) in your replace pattern if you need these spaces in your replacement string.

I just use the assigned keyboard shortcut (or type Alt+0160) in SDL Studio Editor to insert a non-breaking space, then I copy and paste it into the replace pattern where I need it - this works best for me. (You cannot tell a regular space from a non-breaking one in the Regex Match AutoSuggest Provider).

There are some examples on http://noradiaz.blogspot.lt/2015/07/a-collection-of-regular-expressions-for.html – maybe they will be useful.

[Edited at 2017-07-12 16:47 GMT]


Direct link Reply with quote
 

Fredrik Pettersson  Identity Verified
Hong Kong
Member (2009)
English to Swedish
+ ...
TOPIC STARTER
Do I need to remove the 100 % match segments first to get it to work? Jul 13

To get the period to a comma works fine now, but I still can't get it to work with the insertion of space as thousand separator instead of the English standard comma.

I did as you suggested and inserted the symbol (a big circle) for a non-breaking space in Studio's editor (inserted it randomly in a segment). And then copied this and pasted in the Regex editor where I need it (between $1 and $2 and $3). But here, in the Regex editor, there is no symbol displaying (no big circle, like in the Studio editor). Is that as it should be?

And then, I already have all these segments with, for example, a number like 1,842,700, which has been automatically translated by Studio as 1.842.700 (is wrong, should be 1 842 700) and then confirmed as 100 % match. So even if the Regex replace pattern would work, will it work in the end to replace these already 100 % match segments?

While we are discussing this, just wonder how to easily also convert percentage numbers that are written like this in English?:

46%

How can I convert this using Regex so it's written like 46 %? Would it be (\d+) \% (for finding the pattern), and then
$1 $2 (for replacing the pattern)?

But again, it doesn't work for me to insert this non-breaking space.

I'm a bit confused now, because I just found this posting about inserting a non-breaking space between number and percentage sign:

http://www.proz.com/forum/sdl_trados_support/175535-changing_auto_localization_options_for_numbers_in_trados_2009.html


[Edited at 2017-07-13 01:54 GMT]


Direct link Reply with quote
 

Nora Diaz  Identity Verified
Mexico
Local time: 05:18
Member (2002)
English to Spanish
+ ...
A couple of quick things Jul 13



And then, I already have all these segments with, for example, a number like 1,842,700, which has been automatically translated by Studio as 1.842.700 (is wrong, should be 1 842 700) and then confirmed as 100 % match. So even if the Regex replace pattern would work, will it work in the end to replace these already 100 % match segments?




Hi Fredrik,

The Regex Match AutoSuggest Provider won't automatically replace these segments, you would need to go into the segment and start typing the number, manually deleting the existing one. You could, however, use Studio's Find and Replace feature with regex enabled to replace those numbers in your confirmed matches and anywhere else.



While we are discussing this, just wonder how to easily also convert percentage numbers that are written like this in English?:

46%

How can I convert this using Regex so it's written like 46 %? Would it be (\d+) \% (for finding the pattern), and then
$1 $2 (for replacing the pattern)?



[Edited at 2017-07-13 00:33 GMT]


The $1 and $2 refer to the grouped elements in your regex pattern, that is, anything in parentheses. So the $1 represents the same thing that is enclosed in the first parenthesis and the $2 would represent whatever is inside a second set of parentheses, which your example doesn't have.

But in your example you need only one backreference, because the % doesn't change and so you can just place it directly in the replacement pattern. So you would need:

Find: (\d+)%
No need to escape the percent sign, and since the string you're trying to find doesn't have a space between the number and the sign, there shouldn't be a space in your pattern either

Replace: $1 %

That would insert a regular space, though. Sorry I don't have an answer for the non-breaking space.



[Edited at 2017-07-13 01:33 GMT]


Direct link Reply with quote
 

Fredrik Pettersson  Identity Verified
Hong Kong
Member (2009)
English to Swedish
+ ...
TOPIC STARTER
Find and Replace in Studio using the Regex pattern? Jul 13

Hi Nora,

I tried now using Studio's Find and Replace function:

Find what: (d+)%
Replace with: $1 %

But Studio says no matches are found. Isn't it the Regex pattern I should enter in the Find and Replace function?


Direct link Reply with quote
 

NeoAtlas
Spain
Local time: 13:18
English to Spanish
+ ...
Tick Use Regular expressions Jul 13

In the Find and Replace dialog box don't forget to tick Use and select Regular expressions.

Direct link Reply with quote
 

Nora Diaz  Identity Verified
Mexico
Local time: 05:18
Member (2002)
English to Spanish
+ ...
Escape character Jul 14

Fredrik Pettersson wrote:

Hi Nora,

I tried now using Studio's Find and Replace function:

Find what: (d+)%
Replace with: $1 %

But Studio says no matches are found. Isn't it the Regex pattern I should enter in the Find and Replace function?


Hi Fredrik,

Don't forget to escape the "d" with a backslash, that is, \d represents a digit, so (\d+)% will match/find 46%, for example, but (d+)% will match/find dd% or ddd%, for example, as you would be looking for the character d, one or more times, followed by the percent sign.


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 »

Help with Regex Match AutoSuggest Provider for SDL Trados Studio 2015

Advanced search







SDL MultiTerm 2017
Guarantee a unified, consistent and high-quality translation with terminology software by the industry leaders.

SDL MultiTerm 2017 allows translators to create one central location to store and manage multilingual terminology, and with SDL MultiTerm Extract 2017 you can automatically create term lists from your existing documentation to save time.

More info »
Wordfast Pro
Translation Memory Software for Any Platform

Exclusive discount for ProZ.com users! Save over 13% when purchasing Wordfast Pro through ProZ.com. Wordfast is the world's #1 provider of platform-independent Translation Memory software. Consistently ranked the most user-friendly and highest value

More info »



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