Is there a way to combine groups and * regular expression functions to act like a tokenizer / delimiter. I tried this:
my_str = "foofoofoofoo"
pattern = "(foo)*"
result = re.search(pattern, my_str)
I was hoping my bands would look like
("foo", "foo", "foo", "foo")
But this is not so. I was surprised by this because? and group functions work together:
my_str= "Mr foo"
pattern = "(Mr)? foo"
result = re.search(pattern, my_str)
source
share