0

How can I write a regular expression to catch all the words (in MS-Word via script) that are not follow by specific characters, for example:
I would like to catch all the "write" words that does not follow by ':' char

I write: write

In this case the result will be:

write

  • 2
    Does it have to be VBA? In the UI, you can hit Ctrl+H to get the advanced (i.e. legacy) Find and Replace dialog. Check the Use wildcards option, and then for Find what, enter write[!:]. This tells Word to find all instances of write that are not followed by any of the single characters after the ! in the [ ] square brackets, which in your case would be the : colon. – Eiríkr Útlendi Apr 6 '19 at 23:13
  • You right, for some reason I can not mark you remark to "accepted answer" (can not see the button) – hava Apr 7 '19 at 8:20
  • Comments cannot be marked as "accepted", so I'll convert to a proper answer. – Eiríkr Útlendi Apr 7 '19 at 18:19
1

(Converting to answer on asker's suggestion)

If it doesn't have to be VBA:

In the UI, you can hit Ctrl+H to get the advanced (i.e. legacy) Find and Replace dialog. Check the Use wildcards option, and then for Find what, enter write[!:]. This tells Word to find all instances of write that are not followed by any of the single characters after the ! in the [ ] square brackets, which in your case would be the : colon.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.