Could anyone create Regex Search Code to check leading and trailing spaces?
Thread poster: Nam Vo
Nam Vo
Nam Vo  Identity Verified
Vietnam
Local time: 18:30
English to Vietnamese
+ ...
Oct 5, 2019

I'm trying to create a checklist in Xbench to find leading/trailing space mismatch.
I have tried things like [:space:]$, but the search function can only spot non-breaking spaces at the end of segments, not the kind of spaces created when you hit the space key.

Help, please!

[Edited at 2019-10-05 03:07 GMT]

[Edited at 2019-10-05 05:05 GMT]


 
Mikhail Zavidin
Mikhail Zavidin
Local time: 14:30
English to Russian
+ ...
It is simple Oct 5, 2019

Hello, Nam Vo!

It is like this:
^[ ]|[ ]$


Between [ and ] are regular spaces

Hope this helps.


 
Nam Vo
Nam Vo  Identity Verified
Vietnam
Local time: 18:30
English to Vietnamese
+ ...
TOPIC STARTER
Hi Mikhail, Oct 5, 2019

Mikhail Zavidin wrote:

Hello, Nam Vo!

It is like this:
^[ ]|[ ]$


Between [ and ] are regular spaces

Hope this helps.


 
Nam Vo
Nam Vo  Identity Verified
Vietnam
Local time: 18:30
English to Vietnamese
+ ...
TOPIC STARTER
Hi Mikhail, I checked, but unfortunately your code didn't work. Oct 5, 2019

Mikhail Zavidin wrote:

Hello, Nam Vo!

It is like this:
^[ ]|[ ]$


Between [ and ] are regular spaces

Hope this helps.


 
Nam Vo
Nam Vo  Identity Verified
Vietnam
Local time: 18:30
English to Vietnamese
+ ...
TOPIC STARTER
Thank you Oct 5, 2019

Hi Mikhail, I checked, but unfortunately your code doesn't work.
You mean using it to search under
Regular Expressions mode and not using Powersearch (Cltr+P), right?
Unfortunately, it doesn't work.
Could you kindly check, please!

[Edited at 2019-10-05 10:54 GMT]


 
Mikhail Zavidin
Mikhail Zavidin
Local time: 14:30
English to Russian
+ ...
Search Mode combobox Oct 5, 2019

Make sure you have Search Mode combobox set to Regular Expressions option.

 
Mikhail Zavidin
Mikhail Zavidin
Local time: 14:30
English to Russian
+ ...
May be it is because I use the old (2.9) version of Xbench Oct 5, 2019

It does not support Unicode characters.
Which version do you use?


 
Nam Vo
Nam Vo  Identity Verified
Vietnam
Local time: 18:30
English to Vietnamese
+ ...
TOPIC STARTER
I use version 3.0 Oct 5, 2019

The latest version of Xbench actually have this check, but I would like to add this particular function to a checklist, in case my partners forget to check the built-in check option.

 
Mikhail Zavidin
Mikhail Zavidin
Local time: 14:30
English to Russian
+ ...
Well, my Xbench does not recognize starting and trailing spaces of the segment too Oct 5, 2019

I am sorry for misleading you

 
Nam Vo
Nam Vo  Identity Verified
Vietnam
Local time: 18:30
English to Vietnamese
+ ...
TOPIC STARTER
Thanks, Milkhail. Oct 5, 2019

Yeah. No problem.
This was supposed to be easy. Can't believe we can't mimic this function using a simple Regex code.


 
Stepan Konev
Stepan Konev  Identity Verified
Russian Federation
Local time: 14:30
English to Russian
I guess Oct 7, 2019

you cannot do this task with Xbench. The regex suggested by Mikhail is ok, but Xbench cuts all the leading and trailing spaces even if they are there.
If you try smth like [ ][.]$, it will give you all segments ending with space and full stop. This means that the regex itself is ok. However Xbench shows segments from their first 'visible' char to their last 'visible' char [with no spaces at the beginning/end].

Any CAT tool works the same way. Even if there are 3 spaces betwe
... See more
you cannot do this task with Xbench. The regex suggested by Mikhail is ok, but Xbench cuts all the leading and trailing spaces even if they are there.
If you try smth like [ ][.]$, it will give you all segments ending with space and full stop. This means that the regex itself is ok. However Xbench shows segments from their first 'visible' char to their last 'visible' char [with no spaces at the beginning/end].

Any CAT tool works the same way. Even if there are 3 spaces between the sentences in your original file, you will see none.

For example you have a text that goes like this:
This is a simple text to test the leading and trailing spaces control.[ ][ ][ ]I want to know if Xbench can catch them with regex.[ ][ ][ ]Help me do this.[ ][ ][ ]Thank you.

CAT/Xbench presentation wil be like this:
Seg1 This is a simple text to test the leading and trailing spaces control.
Seg2 I want to know if Xbench can catch them with regex.
Seg3 Help me do this.
Seg4 Thank you.

Even if you have extra spaces deliberately inserted at the end of your target segments, Xbench will hide them for segmentation purposes. That is why you cannot find them with Mikhail's regex. No matter what version you use.

[Edited at 2019-10-07 04:42 GMT]
Collapse


Nam Vo
 
pep
pep
Local time: 12:30
English to Spanish
You need to select the "No Whitespace Trimming" check box Oct 10, 2019

Nam Vo wrote:

The latest version of Xbench actually have this check, but I would like to add this particular function to a checklist, in case my partners forget to check the built-in check option.


With Xbench 3.0 build 1434 or later, to find leading or trailing spaces in segments via Search or via a checklist item, you need to select the No Whitespace Trimming checkbox in the Search Options or in the checklist item definition respectively.

Otherwise the segment leading and trailing spaces will be considered to be trimmed in the source and target segments (as was the case with Xbench 3.0 builds before 1434).


Nam Vo
 
Nam Vo
Nam Vo  Identity Verified
Vietnam
Local time: 18:30
English to Vietnamese
+ ...
TOPIC STARTER
Thank you very much, guys. Oct 10, 2019

Thanks very much for your explanation, guys

 


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


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

Could anyone create Regex Search Code to check leading and trailing spaces?






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