Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REGEX matches with 100% confidence, what about 99%?

in my app a user is able to enter text, which later I then search from and extract based on future submission.

Problem is users can sometimes have a type or forget a period, etc...

is there a way in ruby to say match with X% confidence level?

Meaning if the match goal is 500 characters, and a match was found with 490 characters, match it, versus not matching anything?

Thanks

like image 405
AnApprentice Avatar asked Nov 29 '22 04:11

AnApprentice


2 Answers

In this case, regular expressions aren't your best tool. Maybe something like Levenshtein distance instead?

like image 116
John Avatar answered Dec 10 '22 14:12

John


I read about the Tre library recently, sounds like what you are looking for:

http://laurikari.net/tre/

like image 45
ctcherry Avatar answered Dec 10 '22 13:12

ctcherry