Friday, 17 August 2018

regex - Greedy match in MS Word regular expression?


I need to clean up some tables in Word, where semicolons and text after them is redundant, e.g.


text1 ; text 2

where above is a content of one cell and I need to remove semicolon and everything after it until end of cell; unfortunately text 2 doesn't have any specific pattern.


I try to do that with Word's built-in find and replace using regex.


As the desired end of my regular expression is the end of the cell, I can't match it, I've tried several combinations of any character ;?* ;* ;?@ but all stops at the shortest matching text, is there a way to make it match until end of cell?



Answer



This seems to be working:


;[!¤]{1,}

I used generic currency sign ¤, you may use any other symbol you are sure is not included in text following semicolon (maybe it's semicolon itself).


Just a note: leaving curly brackets' second bound empty does not mean an endless string, I found out by trial that the extent is limited to 255 chars.


No comments:

Post a Comment

Where does Skype save my contact'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...