For "small languages" like the one you describe, I use simple split, shlex (the mind that # defines the comment) or regular expressions.
>>> line = 'SOMETHING: !abc @123 #xyz/123' >>> line.split() ['SOMETHING:', '!abc', '@123', '#xyz/123'] >>> import shlex >>> list(shlex.shlex(line)) ['SOMETHING', ':', '!', 'abc', '@', '123']
Below is an example, since I donโt know exactly what you are looking for.
>>> import re >>> result = re.match(r'([AZ]*): !([az]*) @([0-9]*) #([a-z0-9/]*)', line) >>> result.groups() ('SOMETHING', 'abc', '123', 'xyz/123')
user200905
source share