Page 1 of 1

Regex search across paragraph boundaries?

Posted: 2015-06-11 16:59:57
by WiLi
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

Re: Regex search across paragraph boundaries?

Posted: 2015-06-11 19:48:59
by phspaelti
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.

Re: Regex search across paragraph boundaries?

Posted: 2015-06-12 08:52:56
by WiLi
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

Re: Regex search across paragraph boundaries?

Posted: 2015-06-13 08:08:15
by phspaelti
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

Re: Regex search across paragraph boundaries?

Posted: 2015-06-14 03:17:52
by WiLi
… 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