Sql server 如何在字符串值中分隔阿拉伯语和英语文本?
我从以下来源获取数据:Sql server 如何在字符串值中分隔阿拉伯语和英语文本?,sql-server,Sql Server,我从以下来源获取数据: IF LEN(@InString) = 0 SET @ReturnVal = 0 ELSE BEGIN Set @Pos = 1 SET @OutString = ' ' WHILE (@P
IF LEN(@InString) = 0
SET @ReturnVal = 0
ELSE
BEGIN
Set @Pos = 1
SET @OutString = ' '
WHILE (@Pos <= Len(@InString))
BEGIN
Set @CurChar = SUBSTRING(@InString, @Pos, 1)
if unicode(@CurChar) between 1536 and 1791
SET @ReturnVal = @Pos
Set @Pos = @Pos + 1
if @ReturnVal>=1
Break
else
continue
END
end
风道-首次连接
IF LEN(@InString) = 0
SET @ReturnVal = 0
ELSE
BEGIN
Set @Pos = 1
SET @OutString = ' '
WHILE (@Pos <= Len(@InString))
BEGIN
Set @CurChar = SUBSTRING(@InString, @Pos, 1)
if unicode(@CurChar) between 1536 and 1791
SET @ReturnVal = @Pos
Set @Pos = @Pos + 1
if @ReturnVal>=1
Break
else
continue
END
end
我需要将此类数据分为两列,英文文本应分为一列,阿拉伯文文本应分为另一列
IF LEN(@InString) = 0
SET @ReturnVal = 0
ELSE
BEGIN
Set @Pos = 1
SET @OutString = ' '
WHILE (@Pos <= Len(@InString))
BEGIN
Set @CurChar = SUBSTRING(@InString, @Pos, 1)
if unicode(@CurChar) between 1536 and 1791
SET @ReturnVal = @Pos
Set @Pos = @Pos + 1
if @ReturnVal>=1
Break
else
continue
END
end
有人能帮我吗?一个简单的解决方案是(如果可能的话)将数据格式化为以下格式:
IF LEN(@InString) = 0
SET @ReturnVal = 0
ELSE
BEGIN
Set @Pos = 1
SET @OutString = ' '
WHILE (@Pos <= Len(@InString))
BEGIN
Set @CurChar = SUBSTRING(@InString, @Pos, 1)
if unicode(@CurChar) between 1536 and 1791
SET @ReturnVal = @Pos
Set @Pos = @Pos + 1
if @ReturnVal>=1
Break
else
continue
END
end
空气通道-首次连接
IF LEN(@InString) = 0
SET @ReturnVal = 0
ELSE
BEGIN
Set @Pos = 1
SET @OutString = ' '
WHILE (@Pos <= Len(@InString))
BEGIN
Set @CurChar = SUBSTRING(@InString, @Pos, 1)
if unicode(@CurChar) between 1536 and 1791
SET @ReturnVal = @Pos
Set @Pos = @Pos + 1
if @ReturnVal>=1
Break
else
continue
END
end
然后你只需要做一个除以“|”的除法 REGEX
(?P<en>[a-zA-Z-\s]+) (?P<ar>[\w\s]+)
IF LEN(@InString) = 0
SET @ReturnVal = 0
ELSE
BEGIN
Set @Pos = 1
SET @OutString = ' '
WHILE (@Pos <= Len(@InString))
BEGIN
Set @CurChar = SUBSTRING(@InString, @Pos, 1)
if unicode(@CurChar) between 1536 and 1791
SET @ReturnVal = @Pos
Set @Pos = @Pos + 1
if @ReturnVal>=1
Break
else
continue
END
end
(?P[a-zA-Z-\s]+)(?P是测试多种情况的好工具(您可能需要在范围中添加更多字符)
IF LEN(@InString) = 0
SET @ReturnVal = 0
ELSE
BEGIN
Set @Pos = 1
SET @OutString = ' '
WHILE (@Pos <= Len(@InString))
BEGIN
Set @CurChar = SUBSTRING(@InString, @Pos, 1)
if unicode(@CurChar) between 1536 and 1791
SET @ReturnVal = @Pos
Set @Pos = @Pos + 1
if @ReturnVal>=1
Break
else
continue
END
end
我确实删除了^
和$
作为更一般的情况。使用[HRData]
IF LEN(@InString) = 0
SET @ReturnVal = 0
ELSE
BEGIN
Set @Pos = 1
SET @OutString = ' '
WHILE (@Pos <= Len(@InString))
BEGIN
Set @CurChar = SUBSTRING(@InString, @Pos, 1)
if unicode(@CurChar) between 1536 and 1791
SET @ReturnVal = @Pos
Set @Pos = @Pos + 1
if @ReturnVal>=1
Break
else
continue
END
end
去
IF LEN(@InString) = 0
SET @ReturnVal = 0
ELSE
BEGIN
Set @Pos = 1
SET @OutString = ' '
WHILE (@Pos <= Len(@InString))
BEGIN
Set @CurChar = SUBSTRING(@InString, @Pos, 1)
if unicode(@CurChar) between 1536 and 1791
SET @ReturnVal = @Pos
Set @Pos = @Pos + 1
if @ReturnVal>=1
Break
else
continue
END
end
/*对象:用户定义函数[dbo].[StripVenNameAR]脚本日期:2014年1月14日上午8:50:31*/
将ANSI_空值设置为ON
去
IF LEN(@InString) = 0
SET @ReturnVal = 0
ELSE
BEGIN
Set @Pos = 1
SET @OutString = ' '
WHILE (@Pos <= Len(@InString))
BEGIN
Set @CurChar = SUBSTRING(@InString, @Pos, 1)
if unicode(@CurChar) between 1536 and 1791
SET @ReturnVal = @Pos
Set @Pos = @Pos + 1
if @ReturnVal>=1
Break
else
continue
END
end
将带引号的U标识符设置为OFF
去
IF LEN(@InString) = 0
SET @ReturnVal = 0
ELSE
BEGIN
Set @Pos = 1
SET @OutString = ' '
WHILE (@Pos <= Len(@InString))
BEGIN
Set @CurChar = SUBSTRING(@InString, @Pos, 1)
if unicode(@CurChar) between 1536 and 1791
SET @ReturnVal = @Pos
Set @Pos = @Pos + 1
if @ReturnVal>=1
Break
else
continue
END
end
创建函数[dbo]。[StripVenNameAR](@InString as NVarChar(4000))
将smallint返回为
开始
将@ReturnVal声明为smallint
宣布@OutString为NVarchar(4000)
将@Pos声明为smallint
声明@CurChar为NVarChar(1)
设置@ReturnVal=0
IF LEN(@InString) = 0
SET @ReturnVal = 0
ELSE
BEGIN
Set @Pos = 1
SET @OutString = ' '
WHILE (@Pos <= Len(@InString))
BEGIN
Set @CurChar = SUBSTRING(@InString, @Pos, 1)
if unicode(@CurChar) between 1536 and 1791
SET @ReturnVal = @Pos
Set @Pos = @Pos + 1
if @ReturnVal>=1
Break
else
continue
END
end
如果LEN(@InString)=0
设置@ReturnVal=0
其他的
开始
设置@Pos=1
设置@OutString=''
而(@Pos=1
打破
其他的
持续
终止
终止
RETURN@ReturnVal
结束
IF LEN(@InString) = 0
SET @ReturnVal = 0
ELSE
BEGIN
Set @Pos = 1
SET @OutString = ' '
WHILE (@Pos <= Len(@InString))
BEGIN
Set @CurChar = SUBSTRING(@InString, @Pos, 1)
if unicode(@CurChar) between 1536 and 1791
SET @ReturnVal = @Pos
Set @Pos = @Pos + 1
if @ReturnVal>=1
Break
else
continue
END
end
去regex或者看看字母的数值。它总是一样的模式吗:先是英语部分,然后是阿拉伯语部分?
IF LEN(@InString) = 0
SET @ReturnVal = 0
ELSE
BEGIN
Set @Pos = 1
SET @OutString = ' '
WHILE (@Pos <= Len(@InString))
BEGIN
Set @CurChar = SUBSTRING(@InString, @Pos, 1)
if unicode(@CurChar) between 1536 and 1791
SET @ReturnVal = @Pos
Set @Pos = @Pos + 1
if @ReturnVal>=1
Break
else
continue
END
end