I have built a regex which should match valid HTTP headers. It works, sort of, on regexr: https://regexr.com/4pnk9, with regex ^([\\w\\-])+:(?!\\s*$).+$
. I am using
You may either use
r"^([\w-])+:(?!\s*$).+$"
or
"^([\\w-])+:(?!\\s*\$).+\$"
Note that inside a non-raw string literal, the double backslashes stand for a single literal backslash. In a raw string literal, you do not need to escape the $
symbol and you only need a single backslash to form a regex escape.