I would like to extract from a text file only some structured patterns.
example, in the text below:
blablabla
foo FUNC1 ; blabliblo blu
I would like to isolate only 'foo FUNC1 ;'.
I was trying to use lark parser with the following parser
foo=Lark('''
start: statement*
statement: foo
| anything
anything : /.+/
foo : "foo" ID ";"
ID : /_?[a-z][_a-z0-9]*/i
%import common.WS
%import common.NEWLINE
%ignore WS
%ignore NEWLINE
''',
parser="lalr" ,
propagate_positions=True)
But the token 'anything' captures all. Is there a way to make it not greedy ? So that the token 'foo' can capture the given pattern ?