I am trying to read a text file and return all lines that do not begin with a #. In python I could easily use list comprehension list
with open('file.txt') as f:
lines = [l.strip('\n') for l in f.readlines() if not re.search(r"^#", l)]
I would like to accomplish the same thing via Groovy. So far I have the below code, any help is greatly appreciated.
lines = new File("file.txt").readLines().findAll({x -> x ==~ /^#/ })