Regular exp matching delimited string excepting trailing delimiters?
aleax at aleax.it
Thu Oct 31 19:53:23 CET 2002
Jeff Kowalczyk wrote:
> Can anyone suggest a reg exp (using re) that will match the entirety of a
> delimited string of values, omitting zero or more delimiters at the end of
> the string? For example:
> from 'A,B,C,123,D,E,,,,,,' with delimiter ',' match 'A,B,C,123,D,E'
> I have (,*\Z) to match the trailing delimiters for removal with string
> slicing, but I'd prefer to directly match the text to keep, or match both
> keep and discard as groups. What would be the syntax for an omission like
> that? Thanks.
but that won't work if you can have e.g. A,B,,,,D,E,Z,,, ("empty fields").
More information about the Python-list