Friday 22 June 2018

regex - What is the easiest way to do PCRE-style regexp search/replace for MS Word?


You can do this by cut+paste to another RTF editor that supports them, but this does all kinds of horrid things if you want to reimport the text, like mess up tracked changes. Is there something like a plug-in that does this, or some feature that I am missing?


Postscript The PCRE functionality I miss most, from most missed to only rarely missed, are:



  1. Match against vertical whitespace - Word has some facility here, but it is limited;

  2. Zero-width expressions;

  3. Test for Unicode properties;

  4. Backreferences; and

  5. Non-greedy matches.



Answer



The wildcards in Microsoft Word are bit like Regular Expressions. This article has more detail.


Standard Regular Expressions compare to Word Regular Expressions as follows:



  • . becomes ?

  • .* becomes *

  • * becomes @ - e.g. lo@t matches lot and loot

  • [] works the same in both

  • () works the same in both

  • \ escapes wildcards in both

  • \b becomes < and > for matching word boundaries


No comments:

Post a Comment

Where does Skype save my contact&#39;s avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...