So I have a huge configuration file.
How do I remove all lines in the file that start with
These lines starting with ## are all comments and not required in the file.
So I have a huge configuration file.
How do I remove all lines in the file that start with
These lines starting with ## are all comments and not required in the file.
Well, your example text seems not to have posted so I’m only guessing, but I think a regex find adn replace would probably work out okay. Maybe try something like ^\s*##.*\n
and replace with nothing?
Works thank you
can you explain me this expression? and can you refer me to a doc for this?
Sure. First it’s regular expression language. There are a lot of documents out there on it. I think the ones I found most useful were the Python Regular Expression HOWTO document. Also the website http://regex101.com lets you do a lot of experimenting.
For this expression it’s pretty easy to break it down.
^
– Means we want to start this match at the beginning of a line.\s*
– Means we will match any amount of whitespace (in case you have a comment line that is indented a little) and the *
means we will grab it ALL.##
– This is the text you’re looking for and it’s prepending a whole line..*
– The .
matches any character and *
means grab it all.\n
– Up to the newline.Regular expressions are a pretty deep well to jump into but very rewarding and useful when you get the swing of it. And I’m hardly particularly good at it, hence using regex101.com a lot to experiment and see how things work out in practice. Hope that helps!