我在数据库中为我的字符串制作模式这里是我的需求:
我必须遍历每条记录,然后我必须使用SQL检查字符串的每个字符
之后我必须连接字符串并显示如下:
//DECLARING STRINGS IN VARIABLES
SET @str = '4444--6699p'
SET @CHS = '%[a-z]'
SET @CHE = '[a-z]'
SET @CHE2 = '[a-z]%'
SET @NUMS = '%[0-9]'
SET @NUME = '[0-9]'
SET @NUME2 = '[0-9]%'
SET @CHR = '-'
//GET THE IDENT OF SLASH
SET @INDENT = (SELECT PATINDEX('%-%', @str));
// CHECH CONTAIN CHARECTER OR NOT
IF PATINDEX('%[a-z]%' , @str) > 0
//BUILT STRING TILL INDENT
SET @CHA = @CHS
while @id <= @INDENT
begin
set @id = @id + 1
SET @CHA = @CHA + @CHE
end
SET @CHA = @CHA + @CHE2
print @CHA
end
//IF NO CHARECTER BUILT HERE
ELSE
print @NUMS + @NUME + @NUME2
但不想串联字符串,因为这是一个模式,但这里是解释
现在看看数据库字符串
// DATABASE EXAMPLES OF STRING
(512) 482-2392
(518) 457-5181
http://www.menupages.com/restaurants/cafe-shane/
https://www.google.com/#q=auto
025-121-3453
429–432–2145
如果记录存在3次或更多其他明智的空白,那么表达式返回为1
(%[0-9][0-9][0-9]%) [0-9][0-9][0-9] - [0-9][0-9][0-9][0-9]
表达式可以像abcz-aaassss-ccv
那样[a-z]{0,3}-[a-z]{0,10}-[a-z]{0,3}
提示:
如果是c sharp,我们会这样做
string builtme;
builtme = builtme + builtme;
ACHEIVEMENT
这里是出示例子
%[a-z][a-z][a-z]% - %[a-z][a-z][a-z][a-z]%-%[a-z][a-z][a-z]%