Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-14-2016, 01:26 PM
WeyldFalcon WeyldFalcon is offline Dissecting a hyperlink with Find Replace Wildcards Windows 10 Dissecting a hyperlink with Find Replace Wildcards Office 2013
Novice
Dissecting a hyperlink with Find Replace Wildcards
 
Join Date: Nov 2016
Posts: 3
WeyldFalcon is on a distinguished road
Default 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?
Reply With Quote
  #2  
Old 11-14-2016, 02:38 PM
macropod's Avatar
macropod macropod is offline Dissecting a hyperlink with Find Replace Wildcards Windows 7 64bit Dissecting a hyperlink with Find Replace Wildcards Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 11-15-2016, 06:11 AM
WeyldFalcon WeyldFalcon is offline Dissecting a hyperlink with Find Replace Wildcards Windows 10 Dissecting a hyperlink with Find Replace Wildcards Office 2013
Novice
Dissecting a hyperlink with Find Replace Wildcards
 
Join Date: Nov 2016
Posts: 3
WeyldFalcon is on a distinguished road
Default

Thank you Paul,
This worked!

On a separate note, what is the regex macro called?
Reply With Quote
  #4  
Old 11-15-2016, 12:02 PM
WeyldFalcon WeyldFalcon is offline Dissecting a hyperlink with Find Replace Wildcards Windows 10 Dissecting a hyperlink with Find Replace Wildcards Office 2013
Novice
Dissecting a hyperlink with Find Replace Wildcards
 
Join Date: Nov 2016
Posts: 3
WeyldFalcon is on a distinguished road
Default

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
Reply With Quote
  #5  
Old 11-15-2016, 12:48 PM
macropod's Avatar
macropod macropod is offline Dissecting a hyperlink with Find Replace Wildcards Windows 7 64bit Dissecting a hyperlink with Find Replace Wildcards Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by WeyldFalcon View Post
On a separate note, what is the regex macro called?
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]
Reply With Quote
Reply

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

Other Forums: Access Forums

All times are GMT -7. The time now is 02:01 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft