In MS Word, need Regex to hide non-highlighed text, and vice-versa
Thread poster: LEXpert
LEXpert
LEXpert  Identity Verified
United States
Local time: 12:25
Member (2008)
Croatian to English
+ ...
Jun 5, 2023



 
Samuel Murray
Samuel Murray  Identity Verified
Netherlands
Local time: 19:25
Member (2006)
English to Afrikaans
+ ...
@Lex Jun 5, 2023

LEXpert wrote:
In MS Word, need Regex to hide non-highlighed text, and vice-versa.


Hide highlighted text:

1. Press Ctrl+H to bring up the Find/Replace dialog.
2. Click the More button.
3. Tick the box "Use wildcards".
4. Click in the Find field and type a question mark.
5. Click Format > Highlight.
6. Click in the Replace field, and make sure there is nothing in it (not even a space).
7. Click Format > Font > Hidden.
8. Click OK.
9. Click Replace All.

At step 7, make sure it's either a tick or nothing, depending on what you want.

To show or hide non-highlighted text, perform step 5 twice (yes, really).

[Edited at 2023-06-05 07:31 GMT]


 
LEXpert
LEXpert  Identity Verified
United States
Local time: 12:25
Member (2008)
Croatian to English
+ ...
TOPIC STARTER
@ Samuel - what I need is to batch-apply this to multiple files at once Jun 5, 2023

Thanks Samuel, but that part isn't really the problem - I do exactly that in single Word files all the time (though you don't actually need to check "Use Wildcards" to use the formatting attributes).
The issue is that my batch editor (Notepad++) doesn't have these formatting search options, but it *does* does allow batched application of regex S/R to multiple Word files. Hence my question as to whether it can be done with regular expressions.


[Edited at 2023-06-05 07:58 GMT]


 
Stepan Konev
Stepan Konev  Identity Verified
Russian Federation
Local time: 20:25
English to Russian
MS Word or Notepad++? Jun 5, 2023

MS Word or Notepad++ have different regular expressions. Which one do you actually need?
By the way how do you open docx files in Notepad++?


 
Samuel Murray
Samuel Murray  Identity Verified
Netherlands
Local time: 19:25
Member (2006)
English to Afrikaans
+ ...
@Lex Jun 5, 2023

LEXpert wrote:
The issue is that my batch editor (Notepad++) doesn't have these formatting search options, but it *does* allow batched application of regex S/R to multiple Word files.

No, the formatting information in Word files is stored in a location that is away from the actual text, so you won't be able to match the formatting with a regular expression.


 
Dan Lucas
Dan Lucas  Identity Verified
United Kingdom
Local time: 18:25
Member (2014)
Japanese to English
For a Word file VBA is probably your best bet Jun 5, 2023

LEXpert wrote:
Hence my question as to whether it can be done with regular expressions.

Think you'd probably need to drop down into VBA for that.
This should give you a sense of what is involved:

https://superuser.com/questions/1513811/ms-word-finding-all-words-highlighted-with-one-specific-color

One key issue is whether the time saved is greater than the time needed to write and test the code.
Another issue is that VBA tends to be a bit slow.

Dan


 
SafeTex
SafeTex
France
Local time: 19:25
French to English
+ ...
TransTool+ Jun 6, 2023

Hello

Install TransTools+ and use the highlighting tool plus the batch processing tool.
TransTools originally used Word macros and VBA, but TransTools + is written in C++, which is even better

I do this type of operation all the time.


 


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


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

In MS Word, need Regex to hide non-highlighed text, and vice-versa






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