SQL-如何匹配从字符串内的随机索引开始的字符串模式
我有以下模式;
AA(AA)–NBXXYYY–CCCCCCCC(CC)–DD(D)
其中括号中的值是可选的,并且可能不存在。
我只想选择字符串的 XX 部分。可以通过巧妙地使用子字符串来完成吗?如果有任何好的意见,我将不胜感激。
编辑: 一个提示可能是我总是可以跳过第一个连字符(-)之前的内容,它总是在那里......但仍然不确定如何实现它。
I have the following pattern;
AA(AA)–NBXXYYY–CCCCCCC(CC)–DD(D)
Where the values in brackets are optional and may not exist.
I want to select only the XX part of the string. Could it be done with clever use of substring? I would appreciate any good input here.
Edit:
A hint might be that I can always skip the stuff before the first hyphen (-), which will always be there... but still not sure how to implement it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用您的样本数据:
With your sample data:
您可以用 C# 编写一个方法来解析文本字段。无论你做什么,无论如何你都在表扫描区域中 - 没有索引将起作用。因此,如果 SQL 限制了您,请继续使用集成的 .NET 运行时。
You can write a method in C# to do the parsing otf the text field. Regardless what you do you are in a table scan area anyway - no index will work. So, if SQL limits you, just move on and use the integrated .NET runtime.