http://qs321.pair.com?node_id=1225521


in reply to Pattern matching

Above could not possibly "print[s] the whole line" for "MODULE " will be missing. As you are capturing any- & everything after "MODULE " with "(.*)", so you would get "C17 (N...)" string. Capture what you actually want.

Surely there must be some other patterns besides one specific case? What are they?

In this specific case, try ...

m{ \b (MODULE \s+ [A-Z]+[0-9]+) \s* [(] .+? [)] }x