使用grep进行模糊字符串匹配

编程入门 行业动态 更新时间:2024-10-14 20:20:37
本文介绍了使用grep进行模糊字符串匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试匹配包含字符串的文件中的行,例如 ACTGGGTAAACTA.如果我愿意

I am trying to match rows in a file containing a string say ACTGGGTAAACTA. If I do

grep "ACTGGGTAAACTA" file

它给了我完全匹配的行.有没有办法允许一定数量的错配(替换、插入或删除)?例如,我正在寻找序列

It gives me rows which have exact matches. Is there a way to allow for certain number of mismatches (substitutions, insertions or deletions)? For example, I am looking for sequences

  • 最多 3 个允许的替代词,例如AGTGGGTAACCAA"等.

  • Up to 3 allowed subtitutions like "AGTGGGTAACCAA" etc.

    插入/删除(部分匹配,如ACTGGGAAAATAAACTA"或ACTAAAACTA")

    Insertions/deletions (having a partial match like "ACTGGGAAAATAAACTA" or "ACTAAACTA")

    推荐答案

    曾经有一个工具叫做 agrep 用于模糊正则表达式匹配,但它被放弃了.

    There used to be a tool called agrep for fuzzy regex matching, but it got abandoned.

    en.wikipedia/wiki/Agrep 有一些历史以及相关工具的链接.

    en.wikipedia/wiki/Agrep has a bit of history and links to related tools.

    github/Wikinaut/agrep 看起来像是一个复兴的开源版本,但我没有测试过.

    github/Wikinaut/agrep looks like a revived open source release, but I have not tested it.

    如果失败,请查看您是否可以为您的发行版找到 tre-agrep.

    Failing that, see if you can find tre-agrep for your distro.

  • 更多推荐

    使用grep进行模糊字符串匹配

    本文发布于:2023-10-23 05:29:10,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1519926.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:字符串   模糊   grep

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!