Post Reply 
[Req] Match 1 or more directory path levels
Apr. 23, 2015, 03:09 AM (This post was last modified: Apr. 23, 2015 03:17 AM by wammie.)
Post: #1
[Req] Match 1 or more directory path levels
I am looking for a pattern to match 1 or more directory path levels, to replace it with just 1 directory path level.

Examples of directory paths to MATCH (Note - "text with possible spaces between words" refers to unknown text strings, and the number of levels is indeterminate):

http://domain/

http://domain/text with possible spaces between words/

http://domain/text with possible spaces between words/text with possible spaces between words/

http://domain/text with possible spaces between words/text with possible spaces between words/text with possible spaces between words/

REPLACE all matches with http://newdomain/

Another way to express this:

MATCH http://domain/--- anything including "/" or spaces any number of times ---/ (up to the last "/")

REPLACE all matches with http://newdomain/

Thanks to anyone that can help!!
Add Thank You Quote this message in a reply
Apr. 23, 2015, 04:53 AM
Post: #2
RE: [Req] Match 1 or more directory path levels
Code:
[Patterns]
Name = "New HTML filter"
Active = FALSE
Limit = 256
Match = "http://domain/(*/)+"
Replace = "http://newdomain/"

HTH
Add Thank You Quote this message in a reply
[-] The following 1 user says Thank You to JJoe for this post:
wammie
Apr. 25, 2015, 12:11 AM
Post: #3
RE: [Req] Match 1 or more directory path levels
(Apr. 23, 2015 04:53 AM)JJoe Wrote:  
Code:
[Patterns]
Name = "New HTML filter"
Active = FALSE
Limit = 256
Match = "http://domain/(*/)+"
Replace = "http://newdomain/"

HTH
Thanks, JJoe!

I'm sure this works fine in Proxomitron. I have a need to do the same thing in Word using it's Find and Replace feature with macros. If you can help in this regard, I'd appreciate it. Otherwise I understand if this is out of scope since it's not exactly Proxomitron.
Add Thank You Quote this message in a reply
Apr. 25, 2015, 03:22 PM
Post: #4
RE: [Req] Match 1 or more directory path levels
(Apr. 25, 2015 12:11 AM)wammie Wrote:  I have a need to do the same thing in Word using it's Find and Replace feature with macros.

I don't have Word to play with but http://word.mvps.org/faqs/general/usingwildcards.htm

So maybe... In two parts

Find : http://domain/(*/){1,}
Replace: http://newdomain/

Find: : http://domain/
Replace: http://newdomain/

HTH
Add Thank You Quote this message in a reply
Apr. 27, 2015, 09:38 AM
Post: #5
RE: [Req] Match 1 or more directory path levels
Word has a "save as" function and one of the save-as types is an .html Web Page...

you could save the original as .html then run that through Proxo and have your web browser save it back as the modified .html...
Add Thank You Quote this message in a reply
[-] The following 1 user says Thank You to ProxRocks for this post:
wammie
May. 02, 2015, 05:58 PM
Post: #6
RE: [Req] Match 1 or more directory path levels
Might as well muddy the waters...

In essence, using the Find/Replace function (Ctrl-H) will work for every iteration it finds, no matter where they occur in a string. IOW, you can nest as many iterations as you wish/need in a single sentence, and Word will find (and replace) each of them, no problem.

Now, if you try to parse a string with a unique word at the front of the "Find...", then you have a problem, and that's where JJoe's solution comes in. However...

I'm not so sure that you can use a regex in the Find/Replace box. But a "more elegant" solution might be to institute a macro, wherein one can have both recursion and a regex. I've found a link (below), and I tried it - it works just like it says on the tin. (The qualifier being that I'm on Word 2010 - I haven't re-loaded any of my previous versions to test them... sorry.)

For the full explanation and some examples, go here: http://stackoverflow.com/questions/26618...word-macro

Coupled with a final step (within the same macro) that sets the unique domain name correctly, I'd think this should do the trick. Wink But of course, the credit for the idea here has to go to JJoe, all I've done is point the way to making this as nearly a one-step solution as I can imagine.


BTW, I confess that I'm curious - why do you need to modify URL strings in Word?


HTH






Oddysey

I'm no longer in the rat race - the rats won't have me!
Add Thank You Quote this message in a reply
[-] The following 1 user says Thank You to Oddysey for this post:
wammie
May. 02, 2015, 10:01 PM
Post: #7
RE: [Req] Match 1 or more directory path levels
(May. 02, 2015 05:58 PM)Oddysey Wrote:  BTW, I confess that I'm curious - why do you need to modify URL strings in Word?

HTH

Oddysey

Thanks everyone for your replies.

I'm managing a Word document collection at my workplace, on SharePoint.

The original structure had multi-level directories. Over time, I've brought most all of the documents into a single directory. Lately the whole structure has been moved to a new server. There are broken hyperlinks so the macro should fix that with the new domain name. There may also be broken links with the old multi-level URLs.

I'm also changing absolute hyperlinks to relative ones. You can see the need then for collapsing the directory levels in the URLs.

The ultimate goal is to take all the Word docs and convert to hml files for a web system.

Of course at my workplace I can't put Proxomitron on my computer.
Add Thank You Quote this message in a reply
May. 03, 2015, 04:34 AM
Post: #8
RE: [Req] Match 1 or more directory path levels
wammie;

Understood. Good luck on getting that conversion to HTML process in place - the sooner the better. Big Teeth





Oddysey

I'm no longer in the rat race - the rats won't have me!
Add Thank You Quote this message in a reply
May. 03, 2015, 06:17 AM
Post: #9
RE: [Req] Match 1 or more directory path levels
I have to say that I personally did something similar when I worked at a major bank in 2008. I saved the Word document as a filtered HTML page, and then used Proxomitron to parse/process the contents into the format I needed.

You may want to check out Notepad++ as well to have more powerful search + replace capabilities:

http://docs.notepad-plus-plus.org/index....xpressions
http://markantoniou.blogspot.ca/2008/06/...sions.html
Visit this user's website
Add Thank You Quote this message in a reply
May. 04, 2015, 03:25 AM
Post: #10
RE: [Req] Match 1 or more directory path levels
I've read, you have to enable wildcards for the dialog or macro.

http://word.mvps.org/faqs/general/usingwildcards.htm Wrote:To begin, you must first turn Wildcards on in the Find/Replace dialog. To do so, bring up the Find dialog, click More and check Use wildcards. In a macro, set .Find.MatchWildcards = True. If you do not do this, Word treats the wildcard characters as if they were ordinary text.

I hoped wammie could create the macro to move through the files and apply the Find/Replace.

There is http://www.funduc.com/word_sr.htm .

funduc Wrote:Word Search and Replace is a freeware macro for Microsoft Word. We created 'WordSR' for those who need a tool to search and replace in Word documents but find Funduc's Search and Replace too powerful for their needs. Word Search and Replace uses the find and replace functions built-in to Microsoft Word. It does not use our Search and Replace product so the available functions are the same as those in the Word 'Find and Replace' dialog. Word Search and Replace can process more than one file by specifying a 'wild card' in the dialog's 'File Mask (with path)' field.

It looks promising but I have no experience with it.
Back up your files!

HTH
Add Thank You Quote this message in a reply
Post Reply 


Forum Jump: