#1
|
|||
|
|||
Dissecting a hyperlink with Find Replace Wildcards
Hello I would like to search my doc for a site link (Alt+F9 enabled to see hyperlinks) and fix a bunch of broken links.
sample links: HYPERLINK "https://mysite/" \l "Folder1/Folder2/Folder3/RandomArticle1.htm" HYPERLINK "https://mysite/" \l "Folder1/Folder2/Folder3/Folder4/RandomArticle2.htm" HYPERLINK "https://mysite/" \l "Folder5/Folder7/RandomArticle3.htm" Desired output: HYPERLINK "https://mysite/" \l "NewFolder/RandomArticle1.htm" HYPERLINK "https://mysite/" \l "NewFolder/RandomArticle2.htm" HYPERLINK "https://mysite/" \l "NewFolder/RandomArticle3.htm" I have tried Regex style in the Wildcard Find Replace Find What: ("https://mysite/" \\l ").*(?=/*=)*/(.*\.htm") Replace With: \1/NewFolder/\2 Close to what I want (works in regex) but not in word, my hunch is word does not have look ahead (?=/*=) Long story short I want to clear out data between a point and the last forward slash in the row, how is that done in Word find replace? |
#2
|
||||
|
||||
You can use RegEx in Word, but only via a macro that calls a RegEx library. Word's wildcard options are akin to a sub-set of RegEx but even that sub-set doesn't have a 1:1 correspondence with RegEx.
As for what you're trying to do, you could use a wildcard Find/Replace, where: Find = (HYPERLINK *\\l )*([!/]@") Replace = \1^34NewFolder/\2
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thank you Paul,
This worked! On a separate note, what is the regex macro called? |
#4
|
|||
|
|||
Hello macropod,
Oh shoot, I swear this worked this morning but now it is placing the New folder at the end. Maybe I need to know more about how you did this, what is the ^34 doing? As far as I can tell it is adding " is that correct? Then what on earth is placing the text and the " after the second captured area? oh wow, I figured it out, if track changes is on it does that. Last edited by WeyldFalcon; 11-15-2016 at 12:27 PM. Reason: forgot to include name |
#5
|
||||
|
||||
Macros are called whatever you want to name them. A RegeEx macro is simply one that uses the RegEx library. See, for example:
http://dotnetslackers.com/Community/...with-Word.aspx Ironically, the code in that link is for finding upper-case words, developed because the writer thought it couldn't be done using wildcards, which it can, see: https://www.msofficeforums.com/word/...tml#post106745
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
find, hyperlink, wildcards |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using wildcards in Find/Replace to change font/case | angie450 | Word | 2 | 05-26-2016 11:09 AM |
Using wildcards how do I Find and Add to, not replace | Stargehzer | Word | 3 | 01-25-2016 09:14 PM |
Use wildcards to replace some characters | mauuuuu5 | Excel | 2 | 12-12-2015 07:27 PM |
Find & Replace: Wildcards (except this pattern) | tinfanide | Word | 6 | 01-26-2014 06:39 AM |
wildcards in find & replace to reverse word order | jeffk | Word | 3 | 11-11-2012 01:47 PM |