I have a large set of strings, and am looking to extract a certain part of each of the strings. Each string contains a sub string like this:
my_token:[ "key_of_interest" ], This is the only part in each string it says my_token. I was thinking about getting the end index position of ' my_token:[" ' and after that getting the beginning index position of ' "], ' and getting all the text between those two index positions.
Is there a better or more efficient way of doing this? I'll be doing this for string of length ~10,000 and sets of size 100,000.
Edit: The file is a .ion file. From my understanding it can be treated as a flat file - as it is text based and used for describing metadata.
json.loadsand access it on the parsed object, don't try to slice it as a string.my_tokenappears in each string, without an additional constraint (such as 'it is likely to be in the last half of the string'), what sort of efficiency improvement are you looking for? I think you could get a marginal increase in efficiency using regex to simply capturekey_of_interestby making a regex for the surrounding characters, but not to an algorithmically significant degree.my_token". Feel free to disregard.