Last active
December 20, 2015 23:44
-
-
Save parthpower/4cdb7f5510aaa948cd80 to your computer and use it in GitHub Desktop.
Function to get string between start identifier and end identifier string.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Released under MIT license. | |
__author__ = 'Parth Parikh' | |
__license__ = 'MIT' | |
def find_by_identifier(data,startIdentifier,endIdentifier): | |
result = [] | |
identLen = len(startIdentifier) | |
##First check | |
##print(identLen) | |
startIdentIndex = -1 | |
startIdentIndex = data.find(startIdentifier,startIdentIndex+1) | |
endIdentIndex = data.find(endIdentifier,startIdentIndex+identLen) | |
if endIdentIndex == -1: | |
return [] | |
while startIdentIndex!=-1: | |
#print("%d-%d"%(startIdentIndex,endIdentIndex)) | |
result.append(data[startIdentIndex+identLen:endIdentIndex]) | |
#print(data[startIdentIndex+identLen:endIdentIndex]) | |
startIdentIndex = data.find(startIdentifier,startIdentIndex+1) | |
endIdentIndex = data.find(endIdentifier,startIdentIndex+identLen) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment