Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find any summary that does not end with a dot

I am looking for consistency in my projects. But I don't always remember that it when I am typing. This leads me to an issue when I have commented half of my project and I don't know if I ended all the lines with a .

So, I'd like to find all the summaries that does not end with a dot to remedy this. An example of this is:

    /// <summary>
    /// This is my summary
    /// </summary>

This means that there is starting white spaces, always three / and they are all enclosed within a <summary> tag.

I started working on it and got this:

^///$[^\.]

based on

^ start of line
/// the three slashes
$ end of line
[^\.] that doesn't end with a dot.

But I fail to get it to work. How do I find all the summary lines that does not end with a .?

like image 538
default Avatar asked Jan 16 '23 10:01

default


1 Answers

You do not need to anchor to the start of the string, as it is the '///' that marks the the start of a comment line

///.*[^\.]$

how we build this up.

we know that the comments we are looking for start with '///' and end with not '.', those two strings can be matched as '///' and '[^.]' in between we can have anything, so '.*'

You do not need a '^' at the start, as a comment does not have to start at the start of the string/line.

You might also want to account for trailing white space, so

///.*[^\.]\s*$

I might have missed a few other points, so just shout up

what does $ mean

The '$' symbol in regex is an anchor for the end of the string. It sort of matches new lines, except (perhaps depending on implementation) it can match simply the end of input. It works the same as '^' which matches the start of input

like image 106
thecoshman Avatar answered Jan 29 '23 11:01

thecoshman