[Tutor] Testing a string to see if it contains a substring

dw bw_dw at fastmail.fm
Wed Jan 21 19:14:42 CET 2015

Hello Python Friends.
I have a string array, called "line_array".

There may be up to 50 or more elements in the array.
- line_array[1] may contain "01/04/2013  10:43 AM        17,410,217
- line_array[2] may contain "01/25/2013  03:21 PM        17,431,230
- line_array[3] may contain "\n"

I want to retain all elements which are valid (i.e. contains a date
value xx/xx/xxxx)
So I'm using a regex search for the date value located at the start of
each element...this way

misc_int1 =

This method works really well when the regex date characters are found.
It returns the value 0 to misc_int1 because the date regex starts at 0
I was hoping the .start() method would return a -1 value for the
instance in which the regex search string is not found.
That way I could iterate through the elements and retain only the valid

However, the .start() method throws an error if the regex search string
is not found.

Your suggestions greatly appreciated!
d :-]

 Bw_dw at fastmail.net

More information about the Tutor mailing list