Reply to topic  [ 4 posts ] 
Find BBCode element 
Author Message
User avatar

Joined: 2004-04-26 10:20:33
Posts: 44
Location: London, UK
I haven't used Nisus macro language for a couple of years so have forgotten all the complicated stuff!

I want to find the following in a Nisus document and replace it with a space: [color=aaaaa]
where 'aaaaa' is the name of a color which could be different each time I run the macro.
I'm converting documents containing BBCodes into HTML codes and don't need the "color" option currently.

I've tried something like: /[color=.+\]
but it doesn't work.
Can't find any reasonable examples anywhere.

_________________
Geoff Roynon
Mac Pro 2.66MHz, MacOS X 10.8.1
NW Pro 2.0.4


2010-08-16 12:00:32
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
You've almost got it right. In the expression you've given, you want to use a backslash at the start, instead of the forward slash you have there. Putting it into a macro file is easy enough:
Code:
Find and Replace '\[color=.+\]', ' ', 'Ea'

You can see the first argument is the expression, followed by what you want to replace it with (a single space). The final argument is the options string, "E" for PowerFind Pro, and "a" for replace all.

Oh, one tip: I used single quotes for the expression string. That's almost always better than using double-quotes, which do extra pre-processing (interpolation) and would make your expression mean something different.


2010-08-16 14:56:19
Profile WWW
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
One additional consideration. Looking at the text:
Quote:
aaa [color=red] xxx [color=blue] bbb

The existing expression you have will match:
Quote:
[color=red] xxx [color=blue]

Because the ".+" expression is greedy. To make it stingy, follow the "+" with a question mark, eg:
Code:
Find and Replace '\[color=.+?\]', ' ', 'Ea'


2010-08-16 14:59:50
Profile WWW
User avatar

Joined: 2004-04-26 10:20:33
Posts: 44
Location: London, UK
Thanks Martin, that works well.

_________________
Geoff Roynon
Mac Pro 2.66MHz, MacOS X 10.8.1
NW Pro 2.0.4


2010-08-16 23:59:29
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: Bing [Bot] and 2 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:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software