New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
发现一个匹配bug #82
Comments
经测试,未发现bug |
第一个问题,你对WordsSearchResult的End有误解。。。 |
我看代码注释中写的是结束位置。。。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
第一个问题是匹配位置的问题:
在
WordsSearch.cs
FindAll 方法中list.Add(new WordsSearchResult(keyword, i + 1 - keyword.Length, i, item));
这样计算出来的位置有很大偏差
经过我仔细计算后,应该是这样的
其中 FindFirst 也是一样的问题。
第二个问题还是匹配位置的问题:
如果匹配的内容中有 \r、\n 这类的字符,那么实际计算出来的位置要减去这类字符的数量
比如我有如下测试文本:
以 “强奸” 这个词为例
正常匹配出来的开始位置应该是 80,结束位置是82
但实际结果是:79,81
问题是因为在
其辩护人为他做了轻罪辩护。
这句后面有个 \n 符号以上两个结果是基于第一问题我改了代码后匹配出来的位置。
The text was updated successfully, but these errors were encountered: