Regular expressions

Grant Edwards invalid at invalid.invalid
Tue Nov 3 09:56:00 EST 2015


On 2015-11-03, Tim Chase <python.list at tim.thechases.com> wrote:
> On 2015-11-02 20:09, Seymore4Head wrote:
>> How do I make a regular expression that returns true if the end of
>> the line is an asterisk
>
> Why use a regular expression?
>
>   if line[-1] == '*':

Why use a negative index and then a compare?

    if line.endswith('*'):

If you want to know if a string ends with something, just ask it!
    
;)
    
-- 
Grant Edwards               grant.b.edwards        Yow! RELATIVES!!
                                  at               
                              gmail.com            



More information about the Python-list mailing list