在 .NET 中查找子字符串匹配的结尾
我试图在字符串中查找与特定区域性下的另一个字符串匹配的子字符串的索引(由 System.CultureInfo 提供)。
例如,在德国文化下,字符串“ass”与“straße”中的子字符串“aß”匹配。
找到比赛开始的索引,是否有一种简单的方法来识别匹配的是 2 个字符,而不是 3 个?
culture.CompareInfo.IndexOf(value, substring);
我可以使用但不诉诸暴力来
I am trying to find the index of a substring in a string that matches another string under a specific culture (provided from a System.CultureInfo).
For example the string "ass" matches the substring "aß" in "straße" under a German culture.
I can find the index of the start of the match using
culture.CompareInfo.IndexOf(value, substring);
but without resorting to brute force, is there an easy way of identifying that 2 characters were matched, and not 3?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用捕获组,则可以捕获找到的精确匹配,并从中确定匹配的字符数。
我现在有点时间举个例子,所以我希望你能从我的描述中弄清楚。
也许我稍后会修改我的答案。
戴夫
If you use a capture group, you can capture the exact match that was found, and from that you can determine how many characters were matched.
I'm a bit timestressed right now to give an example, so I hope you can figure it out from my description.
Perhaps I'll ammend my answer later.
Dave
正则表达式是否处理 ss 与 ß 的区别?
Does regular expressions handle that distinction of ss vs. ß?