Regex for %s
Thread poster: Omer Shani
Omer Shani
Omer Shani  Identity Verified
Israel
Local time: 01:40
Member (2012)
English to Hebrew
+ ...
Dec 10, 2021

We have several project that contains the following variable: %s or similar ones.
We can't run a usual regex for it turns to be greedy and we are puzzled how to solve it to recognize the variable only, not more not less.
Any ideas?


 
Samuel Murray
Samuel Murray  Identity Verified
Netherlands
Local time: 00:40
Member (2006)
English to Afrikaans
+ ...
@Omer Dec 10, 2021

Omer Shani wrote:
We can't run a usual regex for it turns to be greedy and we are puzzled how to solve it to recognize the variable only, not more not less.

Nope. MemoQ uses .NET regex, but there isn't anything in it about % going greedy:
https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference


 
Tomás Cano Binder, BA, CT
Tomás Cano Binder, BA, CT  Identity Verified
Spain
Local time: 00:40
Member (2005)
English to Spanish
+ ...
Add Regex tagger as a cascading filter to your import filter Dec 10, 2021

You have an easy way of doing this. When you import, import with options, then add a Regex Tagger filter thus creating a cascading filter. In the Import dialog box, click the Regex tagger filter and enter this in the dialog box:
________Captura de pantalla 2021-12-10 132734

The two letters in brackets allow you to also consider %d if you want that. If you have placeholders other than %s or %d, you can add more letters here. I hope this helps!


 
Omer Shani
Omer Shani  Identity Verified
Israel
Local time: 01:40
Member (2012)
English to Hebrew
+ ...
TOPIC STARTER
Thank you! Dec 10, 2021

Thank you Tomas & Samuel.
Your comments were very helpful

Omer


 
Tomás Cano Binder, BA, CT
Tomás Cano Binder, BA, CT  Identity Verified
Spain
Local time: 00:40
Member (2005)
English to Spanish
+ ...
Great! Dec 10, 2021

Omer Shani wrote:
Thank you Tomas & Samuel.

You are most welcome. Personally, I find memoQ's approach to Regex a bit confusing because it is handled differently depending on the feature. For instance, the Regex for "%s" in the Autotranslatables feature requires a different syntax.

Mentioning Autotranslatables, this is another area that is extremely useful in the context of localization. I encourage you to have a look! It might save you a lot of time in certain situations!


 
Anthony Rudd
Anthony Rudd

Local time: 00:40
German to English
+ ...
Regex for %s Dec 11, 2021

%s is not really a regex. By "not really", I mean in regex, a string always matches itself (except when the string contains regex syntactical elements). As such, %s is "greedy" only when the associated operation (possibly implicitly) is "greedy" (such as find and replace all).
How do you want to handle %s?


 


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


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

Regex for %s






CafeTran Espresso
You've never met a CAT tool this clever!

Translate faster & easier, using a sophisticated CAT tool built by a translator / developer. Accept jobs from clients who use Trados, MemoQ, Wordfast & major CAT tools. Download and start using CafeTran Espresso -- for free

Buy now! »
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

Buy now! »