yurkinx
yurkinx

Reputation: 11

How to find a pattern in the string that contains this pattern with typo

I'm trying to implement a function that will find the pattern in the string that contains this pattern with typo. The pattern may contain from 1 to number of words. If pattern has number of words, the sentence also may contain this pattern without whitespaces.

Let's say, find pattern "pattern match" in the sentence "function that will find a pattornmatch"

As I see for now, I need to create array of all combinations of words without whitespaces ("function", "functionthat", "functionthatwill", "that", "thatwill"...) and check each token with levenshtein function.

Is there more elegant solution? It would be great to have something like: preg_match_levenshtain($sentence,$pattern, $maxdistance);

Upvotes: 0

Views: 95

Answers (1)

user2604219
user2604219

Reputation: 1

If you dont expect to have smth right which is subfix of pattern scan with kind of like search. So you will replace "pattern" with "pattern "

Upvotes: 0

Related Questions