简体   繁体   中英

Approximate matching of regular expressions in java

i am looking something similar to commons-text -LevenshteinDetailedDistance but for regular expressions.

e.g 
    LevenshteinDetailedDistance d = new LevenshteinDetailedDistance();
     LevenshteinResults levenshteinResults = d.apply("SomeText", "Some Text");
the result will be like below 
Distance: 1, Insert: 1, Delete: 0, Substitute: 0

//means - string are different by 1 character

Is there any similar library for approximate matching of regular expressions in java ?

eg .

String regularEX = ".*Some Text 1.*"

Pattern pattern = Pattern.compile(regularEX, Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);

pattern.matcher("anyPrefixText Some Text").matches(); // this will retrun false  - but as only one chatterer is missing - i want to get that difference 

Is there any inbuilt library that i can use for this ?

i have already seen below questions but they are not helping Approximate regular expression library for Java? Partial Matching of Regular Expressions Partial matching of Regular expression

I don't thing there is such a library. I'm not aware of anything that tells you how far you missed a match by.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM