php - 如何从两个标签中删除多个子字符串

标签 php string

给定一个这样形成的字符串:

hello Rose <tag> Micheal </tag> and <tag> July </tag> John. 

我想删除 <tag> 之间的所有内容和 </tag>并有输出:

hello Rose and John. 

我该怎么做?

最佳答案

我猜你可以使用:

$new_html = preg_replace('%<tag>.*?</tag> ?%si', '', $old_html);

关于php - 如何从两个标签中删除多个子字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43516138/

相关文章:

php - 从 Excel 电子表格导入高级表单字段

javascript - AngularJS 中的字数统计

c++ - std::string s() 奇怪的行为

c++ - 字符串连接错误

python - 尝试根据大小写将一个字符串解析为两个单独的字符串

php - 在 JQuery 中解析 JSON 并设置输入

php - 直接解析文件上传,不写入文件系统

php - Yii 2.0 从没有小部件的模型中获取数据

python - Python 中的 String.strip()

php - 什么阻止了 fsockopen?