I am fairly new to Python, and I am learning about Regexes right now, which has been a bit of a challenge for me. My issue right now is I am working on a problem that is to create a function that is a Regex version of the strip() string method.
My problem is that I can't figure out how to convert a character that user inputs into a regex without listing out every possibility in the program with if statements. For instance:
def regexStrip(string, char):
if char = 'a' or 'b' or 'c' etc...
charRegex = re.compile(r'^[a-z]+')
This isn't my full program just a few lines to demonstrate what I'm talking about. I was wondering if anyone could help me in finding a more efficient way to convert user input into a Regex.