[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: KATE & regex search/replace across multiple lines



On Fri, 19 Jun 2020 at 13:10, Gary Dale <gary@extremeground.com> wrote:
>
> I've opened another (previously saved) session and tried it there and
> KATE recognizes the \n properly so it's not the version of KATE that's
> at fault. I've tried switching the End-Of-Line mode between Unix and
> MS-DOS (and back) but that didn't help. I can't find any setting that
> deals with the issue.

Have you also made absolutely sure that there isn't any trailing
whitespace on your lines that might be interfering with the RE?

> I did the same thing today (but saved a different page) but I can't get
> the regex to match beyond a single line. When I add a \n at the end of
> the regex, it finds 0 matches (if I instead add a $, it reports the same
> number of matches as the initial regex, so my regex is finding to the
> end of the line).

I've found that Kate struggles with beginning/end of line references
(^ & $). I don't know the specifics of the RE engine, but combining ^,
$ and \n is almost certain to fail. Kate also struggles with some more
advanced or esoteric features of RE, so I'm assuming you've tried
rewording your RE.

So are you _certain_ that the only addition that turns a matching RE
to a failing RE is the \n? When I'm troubleshooting, I test chunks of
my RE to make sure that I haven't made a typo in each chunk. In this
case, if I have something like
"(\d{4}-\d{2}-\d{2})\n([^\n]+)\n([-,\d\.]+)", I check to make sure
that (\d{4}-\d{2}-\d{2}) can match a date line, ([^\n]+) can match a
description line (.*\n might work, but I leave as little
interpretation as possible open to Kate), and ([-,\d\.]+) can match an
amount. Then I string them together one \n at a time until the RE
fails.


Reply to: