My string_first
matches with both pattern
and pattern_second
(see code below). However, I would like for it to be matched only with pattern_second
. Could someone help me in achieving this?
import re
string_first = "this-is-first-time"
pattern = "this-is-first"
pattern_second = "this-is-first.*"
if re.search(pattern, string_first):
print("string match for pattern first")
else:
print("string not match")
if re.search(pattern_second, string_first):
print("string match for pattern second")
else:
print("string not match")