Re: Newbie: Check first two non-whitespace characters

2016-01-01 Thread Jussi Piitulainen
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?

Re: Newbie: Check first two non-whitespace characters

2016-01-01 Thread Karim
On 01/01/2016 00:25, Mark Lawrence wrote: On 31/12/2015 18:54, Karim wrote: On 31/12/2015 19:18, otaksoftspamt...@gmail.com wrote: 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: '[{...'

Re: Newbie: Check first two non-whitespace characters

2015-12-31 Thread Cory Madden
I would personally use re here. test_string = ' [{blah blah blah' matches = re.findall(r'[^\s]', t) result = ''.join(matches)[:2] >> '[{' On Thu, Dec 31, 2015 at 10:18 AM, wrote: > I need to check a string over which I have no control for the first 2 > non-white

Re: Newbie: Check first two non-whitespace characters

2015-12-31 Thread MRAB
On 2015-12-31 18:18, otaksoftspamt...@gmail.com wrote: 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?

Re: Newbie: Check first two non-whitespace characters

2015-12-31 Thread Karim
On 31/12/2015 19:54, Karim wrote: On 31/12/2015 19:18, otaksoftspamt...@gmail.com wrote: 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 ' [ {

Re: Newbie: Check first two non-whitespace characters

2015-12-31 Thread Karim
On 31/12/2015 19:18, otaksoftspamt...@gmail.com wrote: 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?

Newbie: Check first two non-whitespace characters

2015-12-31 Thread otaksoftspamtrap
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? --

Re: Newbie: Check first two non-whitespace characters

2015-12-31 Thread cassius . fechter
Thanks much to both of you! On Thursday, December 31, 2015 at 11:05:26 AM UTC-8, Karim wrote: > On 31/12/2015 19:54, Karim wrote: > > > > > > On 31/12/2015 19:18, snailp...@gmail.com wrote: > >> I need to check a string over which I have no control for the first 2 > >> non-white space

Re: Newbie: Check first two non-whitespace characters

2015-12-31 Thread Steven D'Aprano
On Fri, 1 Jan 2016 05:18 am, otaksoftspamt...@gmail.com wrote: > 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: Newbie: Check first two non-whitespace characters

2015-12-31 Thread Random832
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?

Re: Newbie: Check first two non-whitespace characters

2015-12-31 Thread Mark Lawrence
On 31/12/2015 18:54, Karim wrote: On 31/12/2015 19:18, otaksoftspamt...@gmail.com wrote: 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 ' [ {

Re: Newbie: Check first two non-whitespace characters

2015-12-31 Thread Steven D'Aprano
On Fri, 1 Jan 2016 10:25 am, Mark Lawrence wrote: > Congratulations for writing up one of the most overengineered pile of > cobblers I've ever seen. You should get out more. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie: Check first two non-whitespace characters

2015-12-31 Thread Denis McMahon
On Thu, 31 Dec 2015 10:18:52 -0800, otaksoftspamtrap wrote: > Best to use re and how? Something else? Split the string on the space character and check the first two non blank elements of the resulting list? Maybe something similar to the following: if [x for x in s.split(' ') if x !=

Re: Newbie: Check first two non-whitespace characters

2015-12-31 Thread Cameron Simpson
On 31Dec2015 18:38, MRAB wrote: On 2015-12-31 18:18, otaksoftspamt...@gmail.com wrote: 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