engine.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:refextract 作者: inspirehep 项目源码 文件源码
def find_substring_ignore_special_chars(s, substr):
    s = s.upper()
    substr = substr.upper()
    clean_s, dummy_subs_in_s = re.subn('[^A-Z0-9]', '', s)
    clean_substr, dummy_subs_in_substr = re.subn('[^A-Z0-9]', '', substr)
    startIndex = clean_s.find(clean_substr)
    if startIndex != -1:
        i = 0
        real_index = 0
        re_alphanum = re.compile('[A-Z0-9]')
        for real_index, char in enumerate(s):
            if re_alphanum.match(char):
                i += 1
            if i > startIndex:
                break

        return real_index
    else:
        return -1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号