all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Regex matching summary blocks in C#
@ 2023-12-03 12:07 Samvid Mistry
  2023-12-03 13:39 ` Yuri Khan
  0 siblings, 1 reply; 6+ messages in thread
From: Samvid Mistry @ 2023-12-03 12:07 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-12-03 15:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-03 12:07 Regex matching summary blocks in C# Samvid Mistry
2023-12-03 13:39 ` Yuri Khan
2023-12-03 14:19   ` Samvid Mistry
2023-12-03 14:30     ` Yuri Khan
2023-12-03 14:56       ` Samvid Mistry
2023-12-03 15:15         ` tomas

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.