Iterate through String with multiple lines

groovy, java, loops, string

Solution

One Groovy option would be:

def data = '''# some useless text
             |# even more
             |finally interesting text'''.stripMargin()

List lines = data.split( '\n' ).findAll { !it.startsWith( '#' ) }

assert lines == [ 'finally interesting text' ]

Problem

I got some data: ``` def data = "# some useless text\n"+ "# even more\n"+ "finally interesting text" ``` How can I get the "interesting part" of that? So basically all lines, NOT starting with #.

Original source