我有一个字符串“Sql和Java Devloper”我想使用运算符“和”拆分此字符串 [英] I Have An String "Sql And Java Devloper" I Want To Split This String Using Operator "And "

查看:77
本文介绍了我有一个字符串“Sql和Java Devloper”我想使用运算符“和”拆分此字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串sql and java devloper我想用运算符和

I have an string "sql and java devloper" i want to split this string using operator "and"

推荐答案

分割这个字符串如果你看一下split函数在此链接 [ ^ ] - 基于单个字符,你应该能够适应它寻找单词分隔符。如果链接断开,我将复制下面的代码
If you have a look at the split function on this link[^] - which is based on a single character, you should be able to adapt it to look for "word" delimiters. I'll copy the code below in case the link breaks
CREATE FUNCTION [dbo].[fnSplitString] 
( 
    @string NVARCHAR(MAX), 
    @delimiter CHAR(1) 
) 
RETURNS @output TABLE(splitdata NVARCHAR(MAX) 
) 
BEGIN 
	-- a comment in the source
	DECLARE @source varchar(max) = 'http://www.sqlservercentral.com/blogs/querying-microsoft-sql-server/2013/09/19/how-to-split-a-string-by-delimited-char-in-sql-server/'
    DECLARE @start INT, @end INT 
    SELECT @start = 1, @end = CHARINDEX(@delimiter, @string) 
    WHILE @start < LEN(@string) + 1 BEGIN 
        IF @end = 0  
            SET @end = LEN(@string) + 1
       
        INSERT INTO @output (splitdata)  
        VALUES(SUBSTRING(@string, @start, @end - @start)) 
        SET @start = @end + 1 
        SET @end = CHARINDEX(@delimiter, @string, @start)
        
    END 
    RETURN 
END

由于您未对评论做出超过11小时的回复,我将不会使用word而不是char 。但是,如果您遇到某个特定问题(并且已经努力自行解决),那么只需回复,我会尝试进一步帮助

I won't do the work to use a "word" instead of a char as you haven't responded to the comments for over 11 hours. However, if you get stuck on a specific problem (and have made an effort to resolve it yourself) then just respond and I'll try to help further


谢谢......这个解决方案非常好........
thanks....this solution is perfectly fine........


这篇关于我有一个字符串“Sql和Java Devloper”我想使用运算符“和”拆分此字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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