help-gnu-emacs
[Top][All Lists]
Advanced

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

Regex matching summary blocks in C#


From: Samvid Mistry
Subject: Regex matching summary blocks in C#
Date: Sun, 03 Dec 2023 17:37:51 +0530
User-agent: mu4e 1.10.7; emacs 29.1

Hey,

I am trying to write an overlay that will simplify the large `<summary>`
blocks around comments in C# and just keep the content. For example,

```
/// <summary>
/// Gets the value of the counter.
/// </summary>
```

will get simplified to just

```
// Gets the value of the counter.
```

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.
The remaining lines get captured by `///\\s-*<summary>\\s-*\n` somehow.

For example, in

```
    /// <summary>
    /// Initializes a new instance of the
    /// <see cref="Service"/>
    /// class.
    /// </summary>
```

the second capture group only captures ` /// class.` and all lines above
it are captured by the former part of the regex. Not sure what I am
doing wrong here. I haven't put any wildcards that will capture anything
other than whitespace around summary tag. Appreciate any help with
this.

PS: This is my first time using any mailing list. Let me know if I
should be following any conventions while posting.

-- 
Thanks,
Samvid



reply via email to

[Prev in Thread] Current Thread [Next in Thread]