[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Regex matching summary blocks in C#
From: |
Yuri Khan |
Subject: |
Re: Regex matching summary blocks in C# |
Date: |
Sun, 3 Dec 2023 20:39:08 +0700 |
On Sun, 3 Dec 2023 at 19:20, Samvid Mistry <mistrysamvid@gmail.com> wrote:
> I have written a regex that can match the summary blocks, that is
>
> "\\(\\s-*\\)///\\s-*<summary>\\s-*\n\\(.*\n\\)*?\\s-*///\\s-*</summary>"
>
> The first group captures the indentation so that the overlay is indented
> properly. The second group is supposed to capture the text of the block.
> It works fine for single line blocks but for block spanning multiple
> lines, the second capture group only captures the last line of comment.
You have a *? iterator around your second group, so only one line is
captured. I’d try making the sub-regex that matches a single line into
a non-capturing group, then putting a capturing group around the
iterator:
\\(\\(?:.*\n\\)*?\\)
(BTW what is your plan after you get the whole inside of the <summary>
in a single group? Your description makes it look like you’re going to
want to do something to display /// as //.)