I need to match ordered (not sorted) sets of strings separated by /
's, I guess we can call them sentences, but each sentence is stored as one big string. I have a set of sentences to match against. When given an input sentence I need to determine if it matches with one of the sentences in my set. The run time should depend on the length of the input sentence rather than the number of possible sentences to match with. It also needs to support wildcards, so a wildcard would be represented as X
in my matching set, but in the input string this can be anything, but only 1 word.
An example:
Set of sentences:
Hello/my/name/is/paul
Hello/I/am/sam
What/time/is/it/X
Sometimes/the/tree/X/is/green/other/times/it/is/yellow
Garfield/is/my/favorite/cat
Input:
Hello/my/name/is/paul
Would return true since it matches.
Input:
What/time/is/it/now
Sometimes/the/tree/definitely/is/green/other/times/it/is/yellow
Would both return true because of the wildcard
Input:
What/time/is/it/right/now
What/is/your/name
Would both return false, the first comes close, but would need two wildcards. The second doesn't match with anything.
Thanks for any help!