Regex/QA Checker 3.0 > If (word1) and (word2) are both in the sentance
Thread poster: Lenart
Lenart
Lenart  Identity Verified
Luxembourg
Local time: 12:36
Jun 14, 2017

I would like QA checker to show an error every time apples and bananas are in the same segment.

I thought this code in Regex target should do the work: (?=apples)(?=bananas)

but it doesn't

can somebody please explain me where is the error or propose a different code for the same goal?

also, is there some sort of list of regex expressions for QA checker?

thank you,

L


 
Eirik Birkeland
Eirik Birkeland  Identity Verified
Norway
Local time: 12:36
English to Norwegian (Bokmal)
+ ...
Lookaheads, etc. Jun 14, 2017

(?=apples) is an example of a lookahead. This type of pattern is useful in some cases, but is often not essential.

I suggest trying the following:

apples.*bananas|bananas.*apples

This will match
apples, followed by anything, followed by bananas
OR
bananas, following by anything, followed by apples

It's not a very elegant expression, but you can check a demo he
... See more
(?=apples) is an example of a lookahead. This type of pattern is useful in some cases, but is often not essential.

I suggest trying the following:

apples.*bananas|bananas.*apples

This will match
apples, followed by anything, followed by bananas
OR
bananas, following by anything, followed by apples

It's not a very elegant expression, but you can check a demo here:
https://regex101.com/r/kqBCzb/1

It seems to me that the program you are using supports standard PCRE (Perl-compliant regular expressions), and if that is actually the case I highly recommend http://www.regular-expressions.info/ as a concise and powerful resource for regular expressions.
Collapse


 
Lenart
Lenart  Identity Verified
Luxembourg
Local time: 12:36
TOPIC STARTER
Thank you Erik, Jun 15, 2017

that was very helpful!

 
Lenart
Lenart  Identity Verified
Luxembourg
Local time: 12:36
TOPIC STARTER
if source start with («) and target start with anything different then („) Jun 15, 2017

if you can help me out with one more, I would appreciate it

if source start with («) and target starts with anything different then („), send me an error.

So i would need

a code for Regex Source: if segment starts with («)

and

a code for Regex Target: if segment starts with anything else then („)


 
Riccardo Schiaffino
Riccardo Schiaffino  Identity Verified
United States
Local time: 05:36
Member (2003)
English to Italian
+ ...
The regex flavor used by Studio is .NET Jun 15, 2017

Eirik Birkeland wrote:

It seems to me that the program you are using supports standard PCRE (Perl-compliant regular expressions), and if that is actually the case I highly recommend http://www.regular-expressions.info/ as a concise and powerful resource for regular expressions.


Actually, I believe that the regex flavor used by Studio is .NET. A useful free tool to build and check .NET regular expressions is Expresso

An expression you can use could be

(apple|banana).*(banana|apple)


 
Riccardo Schiaffino
Riccardo Schiaffino  Identity Verified
United States
Local time: 05:36
Member (2003)
English to Italian
+ ...
Regex for quotes at the start Jun 15, 2017

Lenart wrote:

if you can help me out with one more, I would appreciate it

if source start with («) and target starts with anything different then („), send me an error.

So i would need

a code for Regex Source: if segment starts with («)

and

a code for Regex Target: if segment starts with anything else then („)


regex for source:


regex for target:
^[^„]

In fact for the source you can also make it more universal, e.g.:

^[«"“]

This would cover any segment that starts with a French, straight or curly double quotes


 
Riccardo Schiaffino
Riccardo Schiaffino  Identity Verified
United States
Local time: 05:36
Member (2003)
English to Italian
+ ...
For more on the use of regex in CAT tools Jun 15, 2017

For more on the use of regular expressions in CAT tools, please see http://www.aboutranslation.com/p/regular-expressions.html



[Edited at 2017-06-15 17:52 GMT]


 
Lenart
Lenart  Identity Verified
Luxembourg
Local time: 12:36
TOPIC STARTER
thank you Jun 16, 2017

for codes and bunch of very useful information

 
Lenart
Lenart  Identity Verified
Luxembourg
Local time: 12:36
TOPIC STARTER
count of an specific word in source and target Jun 20, 2017

I have another related question end would appreciate any help.

Here's the issue: Word "apple" appears 3 times in source sentence. It corresponds to a word "pomme" which also appears 3 times in target.

I would like to check if number of repetition of the word apple is the same as number of repetition of word pomme.

in Verification/qa checker 3.0/Regular expressions I insert this:

Regex source:apple
Regex target:pomme

and I cho
... See more
I have another related question end would appreciate any help.

Here's the issue: Word "apple" appears 3 times in source sentence. It corresponds to a word "pomme" which also appears 3 times in target.

I would like to check if number of repetition of the word apple is the same as number of repetition of word pomme.

in Verification/qa checker 3.0/Regular expressions I insert this:

Regex source:apple
Regex target:pomme

and I choose the condition: Report if warning source and target match but with different count

I run the check and don't get any warnings as I have 3 times apple in source and 3 times pommes in target

However, if I use the same condition and change regex target slightly (Regex target:pomm.*ver.*), I get an warning that a segment includes 3 times apple, but only one time pomm.*ver.* (even though the word pomme vert actually repeats 3 times in target).

Does anybody have an explanation why? It seems as though regex stops counting once it finds a word witch ends with.*
Is there any way to avoid this?

or is there any other way to check if number of repetition of the word apple is the same as number of repetition of word „pomm.*ver.*“?

Thank you

[Edited at 2017-06-20 13:29 GMT]

[Edited at 2017-06-20 13:38 GMT]

[Edited at 2017-06-20 13:46 GMT]

[Edited at 2017-06-21 07:02 GMT]
Collapse


 


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


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

Regex/QA Checker 3.0 > If (word1) and (word2) are both in the sentance







Trados Business Manager Lite
Create customer quotes and invoices from within Trados Studio

Trados Business Manager Lite helps to simplify and speed up some of the daily tasks, such as invoicing and reporting, associated with running your freelance translation business.

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 »