how to use pyparsing for identifiers that start with a constant string

phil_nospam_schmidt at yahoo.com phil_nospam_schmidt at yahoo.com
Tue Jun 14 23:22:44 CEST 2005


I am scanning text that has identifiers with a constant prefix string
followed by alphanumerics and underscores. I can't figure out, using
pyparsing, how to match for this. The example expression below seems to
be looking for whitespace between the 'atod' and the rest of the
identifier.

identifier_atod = 'atod' + pp.Word('_' + pp.alphanums)

How can I get pyparsing to match 'atodkj45k' and 'atod_asdfaw', but not
'atgdkasdjfhlksj' and 'atod asdf4er', where the first four characters
must be 'atod', and not followed by whitespace?

Thanks!




More information about the Python-list mailing list