Power Find(regex) quote meta characters

Get help using and writing Nisus Writer Pro macros.
Post Reply
mpawp
Posts: 3
Joined: 2019-11-15 11:03:03

Power Find(regex) quote meta characters

Post by mpawp »

Hi,

The new Power Find with browser and and meta character items for Power Find Pro is awesome. In its documentation I could not find a command for quoting regex meta characters such as \Q … \E or quotemeta. Is there one? I am searching for such a command because the patterns are simple enough, which makes it unnecessary to delve further into Nisus Writer Macro than the search and replace commands available.

Regards,
Martin
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Power Find(regex) quote meta characters

Post by martin »

Hi Martin: yes you can use \Q...\E to escape meta characters in a regex find pattern. That works in both the regular Find panel and Nisus Writer Pro macros.

Here's a quick example Nisus Writer macro:

Code: Select all

$sub = @string<\d+ \w+>
Find All @String<T\w+ \Q$sub\E \w+>, 'E'
That will match the text:
Test \d+ \w+ end
But will not match:
Test 123 word end
mpawp
Posts: 3
Joined: 2019-11-15 11:03:03

Re: Power Find(regex) quote meta characters

Post by mpawp »

Hi,

Thank you Martin, that does work. I do not know why I did not get that to work. Together with FollowedBy and the other zero-width matches it solves many problems.

Thanks,
Martin
Post Reply