Reputation: 63
I have some files and I want to remove all the code after # (comment out),
maybe I want to import all the file and copy it line by line and ignore the # lines
I don't know what kind of tool or langauge should I use.
For example
AAA
BBB
#123
#456
CCC
I hope I can get
AAA
BBB
CCC
but not
AAA
BBB
CCC
I tried to use regex to do replace the # line in "" but I doesn't work
str.replace(/\r/g,"")
I tried to detect what is the blue area, it said 6 spaces.
Upvotes: 0
Views: 267
Reputation: 10879
As a related answer giving example python code has already been posted, here's a working solution in JavaScript. The RegEx pattern I use also matches Windows-style carriage return line breaks.
var string = `AAA
BBB
#123
#456
CCC`;
console.log(string.replace(/^#.*\r?\n/gm, ''));
Upvotes: 1