我如何...使用Slash'/'CUT字符串 [英] How do I...CUT String using Slash '/'

查看:61
本文介绍了我如何...使用Slash'/'CUT字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的文件号是'CY / EV / 13-14 / 00014'

我希望输出像'EV / 00014'

My Document No is 'CY/EV/13-14/00014'
and i want output like 'EV/00014'

推荐答案

在此处阅读如何使用RegEx进行数据提取...

http://msdn.microsoft.com/en-us/magazine/cc163473.aspx [ ^ ]
Read here how you may use RegEx for data extraction...
http://msdn.microsoft.com/en-us/magazine/cc163473.aspx[^]


plz试试此代码



plz try this code

CREATE TABLE #TempTable(
docNo varchar(500))
INSERT INTO #TempTable (docNo)
VALUES ('CY/EV/13-14/00014')
SELECT * FROM #TempTable


Select SUBSTRING( docNo, charindex('/',docNo, 1)+1,2) + Substring(docNo,LEN(docNo) - Charindex('/',Reverse(docNo))+1,LEN(docNo)) as docNo
FROM #TempTable


使用 CHARINDEX 函数查找'/'字符的索引,提取中间的字符,最后根据需要连接字符串。
Use the CHARINDEX function to find the index of the '/' character, extract the characters in-between and finally concatenate the strings as required.


这篇关于我如何...使用Slash'/'CUT字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆