Is there a way in python to apply a list of regex patterns that are stored in a list to a single string? -


I have a list of regex patterns (stored in list type) that I would like to apply to a string.

If possible, I would like to do this in Python

Thanks in advance.

  re-import func1 (print): print s, "is a good string" def Func2 (s): print s, "a bad string" funcs = {r ". * Pat1. *": Func1, r ". * Pat2. *": Func2} s = "some string with both pat1 and pat2 "Func: func in funcs.items (): if re.search (pat, s): func (s)  

the above code string s for both functions Call because both patterns are matched.


Comments