【问题标题】:evaluating if a string "nearly" matches another评估一个字符串是否“几乎”匹配另一个
【发布时间】:2021-05-14 21:40:23
【问题描述】:

在 psql 中有没有办法找出一个字符串是否与另一个字符串几乎相同?

例如:“This sting, on screen”几乎匹配“This String, on scren”

【问题讨论】:

标签: sql regex postgresql


【解决方案1】:

你可以使用levenshtein函数

CREATE EXTENSION fuzzystrmatch;

select levenshtein('This sting, on screen'::text, 'This String, on scren'::text); 
-- returns 3
select levenshtein('A very diferent texto'::text, 'of other kind of words'::text); 
-- returns 18

https://www.postgresql.org/docs/13/fuzzystrmatch.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-04
    • 2014-01-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多