Regex search across paragraph boundaries?

Everything related to our flagship word processor.
Post Reply
WiLi
Posts: 9
Joined: 2013-08-13 06:58:30

Regex search across paragraph boundaries?

Post by WiLi » 2015-06-11 16:59:57

I was trying to do a search that spans over several paragraphs.

While the "." dot-wildcard does sometimes not work beyond a paragraph border (=the "backwork P-symbol"), I know "[\w\W]" usually works, and it does work here also. But I do not want do search for "anything", but for "anything except '>)' " in the form "[^>)]"

To my surprise it does not work across Paragraph boundaries. Any hints? any work arounds?


Thanks in advance

WiLi

User avatar
phspaelti
Posts: 1015
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Regex search across paragraph boundaries?

Post by phspaelti » 2015-06-11 19:48:59

WiLi wrote:… for "anything except '>)' " in the form "[^>)]"

Code: Select all

 (?:[^>)]|\n)
Generally sets don't include paragraph markers, but you can include them [\n]. The [\W] set actively includes them, which is why [\w\W] finds everything.
philip

WiLi
Posts: 9
Joined: 2013-08-13 06:58:30

Re: Regex search across paragraph boundaries?

Post by WiLi » 2015-06-12 08:52:56

oho,

menni tenku, menni tenku
(for englisch literates: Thank you so much, I will include you into my bedtime prayer)

yes, what such a tiny modification can make a difference …


you saved me a lot of work

You supplied some insider background info about the Regex implementation of NWP. Is there a source to consult for the like?


with greetings from Europe

WiLi

User avatar
phspaelti
Posts: 1015
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Regex search across paragraph boundaries?

Post by phspaelti » 2015-06-13 08:08:15

WiLi wrote:You supplied some insider background info about the Regex implementation of NWP. Is there a source to consult for the like?
From the look of your question, you actually seem to already have some understanding of regex yourself. In many ways, the Nisus Powerfind Pro is quite similar to the regex used in perl, so information for the latter transfers pretty well.

Joe Kissell wrote a good introduction for Powerfind (Pro) of Nisus Classic in his book the Nisus Way, but many things have changed since those days. (The gist is still the same.)

For a more full-bore explanation, some people have recommended:
Mastering Regular Expressions. By Jeffrey E.F. Friedl. O'Reilly Media
philip

WiLi
Posts: 9
Joined: 2013-08-13 06:58:30

Re: Regex search across paragraph boundaries?

Post by WiLi » 2015-06-14 03:17:52

… is quite similar to the regex used in perl …
good to know.

I only was a bit surprised that those paragraph boundaries apply, so I'd like to know about such specialties, or better: I would like to know where to look for such relevant info.

Some years ago I did a lot of Regex with Dreamweaver, where there are no paragraph or line boundaries. On the other hand, DW does not have "look around" capabilities.

Thank You!

WiLi

Post Reply