Could anyone create Regex Search Code to check leading and trailing spaces?
Thread poster: Nam Vo

Nam Vo  Identity Verified
Vietnam
Local time: 01:31
Member (2018)
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
Ukraine
Local time: 20:31
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  Identity Verified
Vietnam
Local time: 01:31
Member (2018)
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  Identity Verified
Vietnam
Local time: 01:31
Member (2018)
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  Identity Verified
Vietnam
Local time: 01:31
Member (2018)
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
Ukraine
Local time: 20:31
English to Russian
+ ...
Search Mode combobox Oct 5, 2019

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

 

Mikhail Zavidin
Ukraine
Local time: 20:31
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  Identity Verified
Vietnam
Local time: 01:31
Member (2018)
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
Ukraine
Local time: 20:31
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  Identity Verified
Vietnam
Local time: 01:31
Member (2018)
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  Identity Verified
Russian Federation
Local time: 21:31
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
Local time: 19:31
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  Identity Verified
Vietnam
Local time: 01:31
Member (2018)
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?

Advanced search






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.

More info »
Déjà Vu X3
Try it, Love it

Find out why Déjà Vu is today the most flexible, customizable and user-friendly tool on the market. See the brand new features in action: *Completely redesigned user interface *Live Preview *Inline spell checking *Inline

More info »



Forums
  • All of ProZ.com
  • Termsøk
  • Jobber
  • Forumer
  • Multiple search