Newbie: Check first two non-whitespace characters
Random832
random832 at fastmail.com
Thu Dec 31 20:31:16 EST 2015
otaksoftspamtrap at 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.
More information about the Python-list
mailing list