Why `.` in PRE 0263 regex?

In PEP 0263, the format for determining the encoding of a Python file is defined as:

coding[:=]\s*([-\w.]+)

Why does it exist .in regular expression, or, alternatively, why does it exist -and \w? As far as I understand, it .matches any character except a newline, so either [-\w]or [.]will correspond to legal names consisting of alphanumeric characters and dashes .

What is the reason that both -\wand .are listed together [-\w.]?

+4
source share
1 answer

. - , -. . , - , a-zA-Z0-9.

- , ., - . .

, \w [a-zA-Z0-9_]. (_), (-).

Python RegEx,

\

LOCALE UNICODE , - ; [a-zA-Z0-9_]. LOCALE [0-9_] , - . UNICODE, [0-9_] , - .

+7

Source: https://habr.com/ru/post/1537663/


All Articles