How to find occurrences of a sub string in a string with fault tolerance of 1 or more characters?
Example.
Source : John Smith
With Fault tolerance 1 Character:
- Sub String 1: Jahn should result to 1
- Sub String 2: Jonn should result to 1
- Sub String 3: Johm should result to 1
- Sub String 4: johm should result to 1 //ignore case
With Fault tolerance 2 Character:
- Sub String 1: Jann should result to 1
- Sub String 2: Joom should result to 1 and etc...
Any Regex Solution ?? Java Pattern Matching? In this case, a method like this
int countOccurrenceWithFaultTolerance(String source, String subString, int faultTolerance) {
// TODO
return 0;
}
Thanks in Advance.
Aucun commentaire:
Enregistrer un commentaire