简体   繁体   English

Java中正则表达式的近似匹配

[英]Approximate matching of regular expressions in java

i am looking something similar to commons-text -LevenshteinDetailedDistance but for regular expressions. 我正在寻找类似于commons-text -LevenshteinDetailedDistance东西,但使用正则表达式。

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 //方法-字符串相差1个字符

Is there any similar library for approximate matching of regular expressions in java ? 是否有任何类似的库可用于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? 我已经看过以下问题,但它们对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. 我不知道有什么能告诉您错过比赛的距离。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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