我有与此类似的字符串
word1/word2/word3/<b>word3</b>
我想通过正斜杠来爆炸这个字符串。这样我就可以得到以下结果。
Array = (
[0] => 'word1',
[1] => 'word2',
[2] => 'word3',
[3] => '<b>word3</b>'
);
但我无法得到上述结果。相反,我得到以下结果
Array = (
[0] => 'word1',
[1] => 'word2',
[2] => 'word3',
[3] => '<b>word3<',
[4] => 'b>'
);
我应该使用什么正则表达式来使用preg_split
函数来实现预期的结果?
答案 0 :(得分:1)
使用DECLARE @email_id NVARCHAR(450)='1', @id BIGINT, @max_id BIGINT, @query NVARCHAR(1000)
SELECT @id=MIN(id), @max_id=MAX(id) FROM [EmployeeInfo ]
WHILE @id<=@max_id
BEGIN
SELECT @email_id=email_id ,@Gift =gift
FROM EmployeeInfo e join PromoInfo p on p.id = e.id
where ID= @id
SET @body = N''+@email_id+'Your Gift Is' +@Gift;
SET @body = @body
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Profile_Name',
@body = @body,
@body_format ='HTML',
@recipients = @email_id,
@copy_recipients = '',
@subject = 'Subject' ;
SELECT @id=MIN(id) FROM [EmployeeInfo ] where id>@id
END
函数和特定的正则表达式模式:
preg_split
$s = 'word1/word2/word3/<b>word3</b>';
$result = preg_split('~(?<!<)/~', $s);
print_r($result);
- 被视为正则表达式表达式
~
- 负面后瞻断言,确保正斜杠(?<!<)/
前面没有/
输出:
<