Reply to topic  [ 5 posts ] 
Find/Replace multiple items 
Author Message

Joined: 2008-02-26 13:46:29
Posts: 18
Pretend I have no idea what I'm doing and that I know nothing about perl.

I have done "Record Marcos" in MS Word and done some editing of those macros.

If I had a series of find/replace commands, what would the structure of that be? I can figure out the regular expressions, but what would the blank object be... sort of like the shell of an html document.

My purpose is to move away from word. I get 100-200 ms word docs a month from various sources with different structures and presentational formatting. I need to get them down to lean, economical, AP style documents with limited presentational markup for import into InDesign.

I've used Word for years, but the scripting is beyond me... I'm looking for something simple and elegant. I think NWP will work, I just need the structure to get started.


2008-02-26 14:20:51
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
The general structure to run multiple find & replace operations in a macro would be this:
Code:
Find and Replace 'FindWhat', 'ReplaceWith', 'options'
Find and Replace 'FindWhat2', 'ReplaceWith2', 'options'


If you want to use normal Find & Replace (eg: not regular expressions / PowerFind) then the options string is simply 'a' to specify replace all, eg:
Code:
Find and Replace 'Foo', 'Bar', 'a'
Find and Replace 'Red', 'Blue', 'a'


If you want to use PowerFind then you'll want to add an 'e', or a capital 'E' for PowerFind Pro, eg:
Code:
Find and Replace '\$(\d+)(?!\.)', '$\1\.00', 'Ea'
Find and Replace '(?<=\s)(\d+)(?!\.)', '[\1]', 'Ea'


2008-02-26 14:52:08
Profile WWW

Joined: 2008-02-26 13:46:29
Posts: 18
Post 
So I just use simple statements according to the models you provided? No Document Declarations (as if I even know what that is) or the anything like Microsoft.Sucks.End.With?

That's almost too easy.

You're saying I could make a simple spreadsheet of the few dozen things I want to correct, write a formula to format those items into text that I save as a macro and Bob's my uncle?

Sweet.


2008-02-26 15:10:40
Profile
User avatar

Joined: 2004-12-14 07:54:49
Posts: 156
Location: Düsseldorf Germany
It was easier even: In Nisus Writer Classic you just macroized your Find/Replace String with a "macroize" button in the lower left corner of the F/R Window.
By the way: will Nisus Writer Pro have such a feature some day?


2008-09-02 08:34:46
Profile WWW
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post Re:
mwiseman wrote:
So I just use simple statements according to the models you provided?

That's exactly right. There's really only one thing that I can think of that would make things more complicated for you: searching for an apostrophe or backslash. You have to "escape" the characters. So, if you wanted to replace the word "it's" you'd precede the apostrophe with a single backslash, eg:
Code:
Find and Replace 'it\'s', 'it is', 'a'


Same thing for backslashes themselves, eg:
Code:
Find and Replace '1\\2', 'one half', 'a'


Matze wrote:
It was easier even: In Nisus Writer Classic you just macroized your Find/Replace String with a "macroize" button in the lower left corner of the F/R Window.
By the way: will Nisus Writer Pro have such a feature some day?

It should indeed- we're looking to add that feature in sometime soon.


2008-09-02 14:50:05
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software