I need to write a part of the program which will work with a string, find in it some substrings and copy they to dictionary. Example of the string:
thestring ='\ #: somethings\nchars0 "substr0"\nchars1 "substr1"\n\n\ #: something\nchars0 "substr2"\nchars1 "substr3"'
so it have current substrings 'chars0' and 'chars1' which I know and some random substrings like 'substr0'...
But it is a small problem - on the start of the string anothoer structure:
'chars0 ""\nchars1 ""\n"words\\n"\n"else words\\n"\n ... '
and then structured string like above.
I know only number of this substrings with words, but I'm not interested in this subtrings, I need substrings only from structured part of the string.
If print the string, we get this:
chars0 "" chars1 "" "some words\n" "else words\n" ... #: something chars0 "subtring" chars1 "else substring" ...
How can I optimize search of it? (I think that it is good to try find() string method or rfind() because of end of the string is structured)