top | item 46798123

(no title)

flufluflufluffy | 1 month ago

The vast majority of the times I use ^/$, I actually want the behavior of matching start/end of lines. If I had some multi-line text, and only wanted to update or do something with the actual beginning or end of the entire text, I’d typically just do it manually.

discuss

order

theamk|1 month ago

A lot of time I want to check for valid identifier:

    if not re.match('^[a-z0-9_]+$', user):
        raise SomeException("invalid username")
as written, the code above is incorrect - it will happily accept "john\n", which can cause all sort of havoc down the line

extraduder_ire|1 month ago

Shouldn't you use the match returned from the string? Or use .fullmatch() (added 3.4) to match the whole string.