使用 preg_replace 进行格式化
图案和更换有困难。如何使替换回显最终产品,例如
INSERT INTO `table` (`person`, `file`) VALUES
('test','test'),
('test2','test2'),
('test3','test3');
我正在尝试将字符串插入 SQL,但我需要格式化下面的当前字符串才能执行此操作,并且我需要字符串的最后一部分 test3: test3 或任何关闭 SQL 模式的文本 ('test3','test3');
<?php
$string = 'test:test test2:test2 test3:test3';
$pattern = '';
$replacement = '';
echo preg_replace($pattern, $replacement, $string);
?>
另外,它也可以有这样的字符串吗? '[电子邮件受保护]:test test2:test2' 而电子邮件始终位于冒号之前。
Having trouble with pattern and replacement. How can I make the replacement echo a final product such as
INSERT INTO `table` (`person`, `file`) VALUES
('test','test'),
('test2','test2'),
('test3','test3');
I am trying to insert the string into SQL but I need to format the current string below to do so, and I need to have the last part of the string test3:test3 or whatever the text may be to close the SQL pattern ('test3','test3');
<?php
$string = 'test:test test2:test2 test3:test3';
$pattern = '';
$replacement = '';
echo preg_replace($pattern, $replacement, $string);
?>
Also, can it also have a string such as this? '[email protected]:test test2:test2'
whereas the email will be before the colon at ALL times.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这样的事情:
解释:
Try something like this:
An explanation: