Q1-PatIndex 模式正则表达式:如何匹配点后跟空格?Q2 -PatIndex 模式正则表达式:如何匹配一个点后跟两个空格?。
我想把它放在这里只得到目标内容
Declare @Temp Table(Data VarChar(1000))
Insert Into @Temp Values('Lalallaa GOAL: This is the truthmeow. Meow. ')
Insert Into @Temp Values('Lalallaa GOAL: This is the truth. Meowrwr. ')
Insert Into @Temp Values('lALALLA GOAL: This is the truth. Meowrwr. NOTINCLUDED: WAWAW')
Select Left(
SubString(Data,PATINDEX ('%GOAL%',Data), 8000) ,
PatIndex('regex here', SubString(Data, PatIndex('%[GOAL]%', Data), 8000))-1)
From @Temp
预期产出
GOAL: This is the truthmeow.
GOAL: This is the truth.
GOAL: This is the truth.
我在真实数据库上使用了 Shnugos 答案,但遇到了一个错误:Illegal name character
我检查了数据类型,它是ntext