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:
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.
Find BBCode element
- GeoffRoynon
- Posts: 48
- Joined: 2004-04-26 10:20:33
- Location: Oxford, UK
Find BBCode element
Geoff Roynon
Mac Studio, MacOS X 14.0 Sonoma
NW Pro 3.3
Mac Studio, MacOS X 14.0 Sonoma
NW Pro 3.3
- martin
- Official Nisus Person
- Posts: 5227
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Find BBCode element
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:
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.
Code: Select all
Find and Replace '\[color=.+\]', ' ', 'Ea'
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.
- martin
- Official Nisus Person
- Posts: 5227
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Find BBCode element
One additional consideration. Looking at the text:
The existing expression you have will match:
Because the ".+" expression is greedy. To make it stingy, follow the "+" with a question mark, eg:
aaa xxx bbb
The existing expression you have will match:
xxx
Because the ".+" expression is greedy. To make it stingy, follow the "+" with a question mark, eg:
Code: Select all
Find and Replace '\[color=.+?\]', ' ', 'Ea'
- GeoffRoynon
- Posts: 48
- Joined: 2004-04-26 10:20:33
- Location: Oxford, UK
Re: Find BBCode element
Thanks Martin, that works well.
Geoff Roynon
Mac Studio, MacOS X 14.0 Sonoma
NW Pro 3.3
Mac Studio, MacOS X 14.0 Sonoma
NW Pro 3.3