Regular expressions

Chris Angelico rosuav at gmail.com
Tue Nov 3 11:20:04 EST 2015


On Wed, Nov 4, 2015 at 3:10 AM, Seymore4Head
<Seymore4Head at hotmail.invalid> wrote:
> Yes I knew that -1 represents the end character.  It is not a question
> of trying to accomplish anything.  I was just practicing with regex
> and wasn't sure how to express a * since it was one of the
> instructions.

In that case, it's nothing to do with ending a string. What you really
want to know is: How do you match a '*' using a regular expression?
Which is what MRAB answered, courtesy of a working crystal ball: You
use '\*'. Everything about the end of the string is irrelevant. (So,
too, are all the comments about using [-1] or string methods. But we
weren't to know that.)

ChrisA



More information about the Python-list mailing list