As shown in this question, Python regex has a neat and concise functionality to fuzzy match one string against the start of a second string (up to x
character changes).
In the following code snippet, x=1
(see e<=1
). The first string is amazing
, and the second string is amagingfiller
.
>>> import regex
>>> regex.match('(amazing){e<=1}', 'amagingfiller')
<regex.Match object; span=(0, 7), match='amaging', fuzzy_counts=(1, 0, 0)>
amazing
matches amaging
because amaging
is 1 or fewer changes from amazing
. filler
is ignored entirely. This is what is expected.
Question 1: Is there any equivalent functionality in Java's regex library?
Question 2: If not, what's an alternative way to solve this?