help-bash
[Top][All Lists]
Advanced

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

Re: Pattern matching lines starting with double comment characters


From: Greg Wooledge
Subject: Re: Pattern matching lines starting with double comment characters
Date: Sat, 25 Feb 2023 09:06:07 -0500

On Sat, Feb 25, 2023 at 11:25:53AM +0000, goncholden via wrote:
> I want to match lines that start with double comment characters in source 
> code files.
> 
> I am currently using
> 
> pn_ere = "^[[:space:]]*([#;!]+|@c|//)[[:space:]]+"​
> 
> The pattern handles possible spaces at the beginning and end of lines.
> 
> But the pattern does not specify double comment characters
> 
> Case of ##
> Case of ;;
> Case of !!

And after we help you with THIS, what's next?  Triple?  Quadruple?
N-tuple?  Another type of comment marker that you previously didn't tell
us about, that you suddenly discovered the need to handle?  Nested comment
markers from multiple languages?  Multi-line comments?

This project is completely insane.  It's the definition of scope creep.

You CANNOT write a shell script that parses files containing EVERY TYPE
OF COMMENT MARKER IN THE WORLD simultaneously.  You CERTAINLY can't do
it with a single regular expression.

Figure out what your ACTUAL NEEDS are, and then write your program to
handle those.



reply via email to

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