Relative Content

Tag Archive for pythonregex

Regex to match a whole number not ending in some digits

I’ve not been able to construct a pattern which can return an whole numbers that don’t end in a sequence of digits. The numbers could be of any length, even single digits, but they will always be whole. Additionally, multiple numbers could be on the same line of text and I want to match them all. The numbers are always followed by either a single space or the end of the line or the end of the text. I’m matching in python 3.12

Escaping regex string

I want to use input from a user as a regex pattern for a search over some text. It works, but how I can handle cases where user puts characters that have meaning in regex?