cannot replace when regex in find field
Thread poster: Uta Schulz

Uta Schulz  Identity Verified
Portugal
Local time: 01:21
Member (2013)
English to German
+ ...
Jul 7, 2016

Hi there,

I have a lot of this in my target:

620x260x440mm (24.4 x10.2x17.3in)

Some have no space others have U00A0, U2000 or what so ever following the numbers. I would like to replace all instances of number + unit/x with number+U202F+unit/x.

So I press Ctrl+H and I enter the following expression into the find field:

( ? < = \\ d ) \\ p {Zs}* ( ? = [xmi] )


I check the case sensitive and regex boxes and find nicely all I want.

Now the promblem: I cannot replace it with my U202F or with anything else. Whenever there is a regex in the find field, the replace field seems not to work anymore.

Ideas anybody?
I use Studio 2015 Freelance and the source is a docx, that I got as a package.

Thanks in advance!
Uta

[Bearbeitet am 2016-07-07 13:34 GMT]


 

Uta Schulz  Identity Verified
Portugal
Local time: 01:21
Member (2013)
English to German
+ ...
TOPIC STARTER
the problem in more detail... Jul 9, 2016

Maybe I should point out the problem in more detail, since nobody reacted:

No problem with any space character (e.g. U2000) or a regex for space characters (e.g. \ p {Zs}) in the find field and another space character (e.g. 00A0) in the replace field. Everything is matching and replacing just fine.

But if I define the space character with a lookbehind (( ? < = \ d) then the replace function does not work, even though it matches the correct characters.

Another try with capture groups in the find field and reference in the replace field also only results partly:
I used this in the find field:
( \ p {Zs} * x \ p {Zs} * ) and
°$1°
in the replace field (° means u202F).

It matches everything correctly. But it only adds the spaces to the x. So if there are already any kind of spaces around the x, they get doubled, because the backreference includes the spaces. Same problem as with include the spaces in the lookbehind. They will not get replaced.

Has anybody an idea for a regex?

[Bearbeitet am 2016-07-09 11:02 GMT]


 

Uta Schulz  Identity Verified
Portugal
Local time: 01:21
Member (2013)
English to German
+ ...
TOPIC STARTER
Answer from another forum Jul 10, 2016

I received this helpful answer in another forum:

About your first regex, it's the same with my Studio 2014: Studio matches but can't replace even if the Replace with field is as simple as foo. (BTW: there are extra espaces and \ in your regex).

About your second regex, I'd say it's the expected behaviour, nothing buggy here.

Maybe you can divide the solution in 2 regexes:

(1/2) This regex will match the X'es:

Find what: (\p{Zs}*)(x)(\p{Zs}*)

Replace with: °$2°

where ° is the non-breakable space

(2/2) This regex will match the in's and mm's

Find what: (\d)(\p{Zs}*)([mi])

or

Find what: (\d)(\p{Zs}*)(mm|in)

Replace with: $1°$3

where ° is the non-breakable space

Anyway, I'd recommend you too the Regex Match Solution Provider (find it here: http://appstore.sdl.com/app/regex-match-autosuggest-provider/412/): You would be able to translate on the fly (which is easier and automatic), not replacing after translation.

Hope it helps.


 


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


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

cannot replace when regex in find field

Advanced search







Anycount & Translation Office 3000
Translation Office 3000

Translation Office 3000 is an advanced accounting tool for freelance translators and small agencies. TO3000 easily and seamlessly integrates with the business life of professional freelance translators.

More info »
SDL Trados Studio 2019 Freelance
The leading translation software used by over 250,000 translators.

SDL Trados Studio 2019 has evolved to bring translators a brand new experience. Designed with user experience at its core, Studio 2019 transforms how new users get up and running, helps experienced users make the most of the powerful features, ensures new

More info »



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