31-增强的strstr
EnhancedStrstr-HUAWEI-CodingInterview

Difficulty Assessment: Easy
Tag: Regular Expression
import re
class EnhancedStrstr:
# Input Part
def GetInput(self)->None:
'''
Get Input Data and Preprocess Data
'''
self.S = input()
self.T = input()
# Algorithm Part
def Solution(self)->int:
'''
Algorithm Solving Problem
'''
# Get data from self
S, T = self.S, self.T
matcher = re.search(T, S)
res = -1
if matcher:
res = matcher.span()[0]
return res
# Execution Part
if __name__ == "__main__":
# Instantiate
obj = EnhancedStrstr()
# Get Input
obj.GetInput()
# Get Result
print(obj.Solution())abcd
b[cd]