otaksoftspamt...@gmail.com writes: > I need to check a string over which I have no control for the first 2 > non-white space characters (which should be '[{'). > > The string would ideally be: '[{...' but could also be something like > ' [ { ....'. > > Best to use re and how? Something else?
Is it an arbitrary string, or is it a JSON object consisting of a list whose first element is a dictionary? Because if you're planning on reading it as a JSON object later you could just validate the types after you've parsed it. -- https://mail.python.org/mailman/listinfo/python-list