Reputation: 19355
I want to do a simple string match, searching from the -front- of the string. Are there easier ways to do this with maybe a builtin? (re
seems like overkill)
def matchStr(ipadr = '10.20.30.40', matchIP = '10.20.'):
if ipadr[0:len(matchIP)] == matchIP: return True
return False
Upvotes: 2
Views: 1653
Reputation: 602715
def matchStr(ipadr = '10.20.30.40', matchIP = '10.20.'):
return ipadr.startswith(matchIP)
Upvotes: 7