News Score: Score the News, Sort the News, Rewrite the Headlines

Regex character “$” doesn't mean “end-of-string”

This article is about a bit of surprising behavior I recently discovered using Python's regex module (re) while developing SBOM tooling for CPython. Folks who've worked with regular expressions before might know about ^ meaning "start-of-string" and correspondingly see $ as "end-of-string". So the pattern cat$ would match the string "lolcat" but not "internet cat video". The behavior of ^ made me think that $ was similar, but they aren't always symmetrical and the behavior is platform-dependent....

Read more at sethmlarson.dev

© News Score  score the news, sort the news, rewrite the headlines