finding a string of random characters (with possible errors) within a large string of random charact
Posted
by mike
on Stack Overflow
See other posts from Stack Overflow
or by mike
Published on 2010-04-01T07:14:55Z
Indexed on
2010/04/01
7:23 UTC
Read the original article
Hit count: 516
I am trying to search a large string w/o spaces for a smaller string of characters. using regex I can easily find perfect matches but I can't figure out how to find partial matches. by partial matches i mean one or two extra characters in the string or one or two characters that have been changed, or one of each. the first and last characters will always match though. this would be similar to a spell checker but there are no spaces and the strings dont contain actual words, just random hex digits.
i figured a way to find the string if there are no extra characters using indexOf(string.charAt(0)) and indexOf(charAt(string.length()-1) and looping through the characters between the two indexes. but this can be problematic when dealing with randomized characters because of the possibility of finding the first and last characters at the correct spacing but none of the middle characters matching.
i've been scratching my head for hours on this issue. any ideas?
© Stack Overflow or respective owner