I have a problem, and while I'm sure that standard regular expressions would work, they seem extremely overkill for the situation.
These threads didn't really help.
I have a collection of substrings Si, and a collection of target strings Ti. I want to compare the list of substrings to each target string, according to the following condition: The substrings must all be present in the target, in order, but they may have any number of characters between them.
Example:
S1 = "i"
S2 = "ow"
S3 = "ped"
T1 = "the quick brown fox jumped over the lazy dog"
T2 = "the rain in spain stays mainly in the plain"
In this example, TI would succeed and T2 would fail.
The comparison basically breaks down to evaluating the regular expression "*i*ow*ped*" on each target string, but this seems wasteful for such a simple problem.
My other idea is to keep lists of which targets pass each substring test, and iterate through Si until either the latest list has no entries (all the targets failed) or it runs out of substrings (one or more targets passed). This takes advantage of two things I know about the situation:
1. The number of substrings will be low (<25 likely)
2. The number of targets could be quite high
Please lend a hand if you see a better way!
These threads didn't really help.
I have a collection of substrings Si, and a collection of target strings Ti. I want to compare the list of substrings to each target string, according to the following condition: The substrings must all be present in the target, in order, but they may have any number of characters between them.
Example:
S1 = "i"
S2 = "ow"
S3 = "ped"
T1 = "the quick brown fox jumped over the lazy dog"
T2 = "the rain in spain stays mainly in the plain"
In this example, TI would succeed and T2 would fail.
The comparison basically breaks down to evaluating the regular expression "*i*ow*ped*" on each target string, but this seems wasteful for such a simple problem.
My other idea is to keep lists of which targets pass each substring test, and iterate through Si until either the latest list has no entries (all the targets failed) or it runs out of substrings (one or more targets passed). This takes advantage of two things I know about the situation:
1. The number of substrings will be low (<25 likely)
2. The number of targets could be quite high
Please lend a hand if you see a better way!