Select Japanese macro

Get help using and writing Nisus Writer Pro macros.
Post Reply
rodthomas
Posts: 6
Joined: 2004-12-13 00:07:20

Select Japanese macro

Post by rodthomas » 2008-02-07 04:09:08

When I was using Classic I had a very useful macro that would select and remove Japanese from a bilingual rtf document. When Express came out this macro wouldnt work any more and I believe I was told it wasnt possible to make one then. What is the situation now with Pro? Can it do this? And if so can some kind person show me how?!
Thanks!

User avatar
Hamid
Posts: 732
Joined: 2007-01-17 03:25:42

Post by Hamid » 2008-02-07 07:37:00

With NWP it should be possible to write a macro which can do what you want. I just tried to write a quick one and it seems to work, but there may be a more elegant way to do the same. You can copy the following expression (use preferably Firefox) and save it as a Nisus Writer Pro macro (with extension .nwm) in the Macro folder and try it in NWP:

Find and Replace '(?:\p{Hiragana}|(?<=\p{Hiragana})\u30FC)|(?:\p{Katakana}|(?<=\p{Katakana})\u30FC)|\p{Han}|\u3001', '', 'Ea'

rodthomas
Posts: 6
Joined: 2004-12-13 00:07:20

Post by rodthomas » 2008-02-07 15:20:55

Thanks! It works.
2 questions
1. How did you know how to do it? I couldnt find it in the NWP manual
2. How do I also remove Japanese punctuation (full stops and quotes etc 。「)?

User avatar
Hamid
Posts: 732
Joined: 2007-01-17 03:25:42

Post by Hamid » 2008-02-08 15:31:16

1. It is not stated in the manual, but the release notes of NWP 1.0.1 mentioned that the PowerFind Pro engine was switched to Oniguruma, and among its new features was Unicode character properties (which allows to find any particular script). This was implemented in PowerFind and PowerFind Pro under Find what: =>Scripts.

2. To remove Japanese text as well as punctuation, you can try the following macro.

Find and Replace '([\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\u3000-\u303F\uFF01-\uFF9F])+|(\u2014{2})|(\u2026{2})', '', 'Ea'

This should take care of both. If anything is missed, do let me know.

rodthomas
Posts: 6
Joined: 2004-12-13 00:07:20

Post by rodthomas » 2008-02-08 16:52:54

Thank you VERY much! This is cool

Post Reply