Php 从字符串或文本中查找下标或上标
如何从下面的文本中删除下标或上标 此处[5][6]为上标 《博伽梵歌》综合了印度教关于佛法的思想[5][6],[5][6][7]有神论的巴克提[8][7]和通往摩克沙的瑜伽之路[6]综合了四条通往灵性的道路 有办法找到它吗?Php 从字符串或文本中查找下标或上标,php,html,Php,Html,如何从下面的文本中删除下标或上标 此处[5][6]为上标 《博伽梵歌》综合了印度教关于佛法的思想[5][6],[5][6][7]有神论的巴克提[8][7]和通往摩克沙的瑜伽之路[6]综合了四条通往灵性的道路 有办法找到它吗? <?php // regex breakdown // \[ matches the left bracket // . any character except line breaks // * 0 or more of t
<?php
// regex breakdown
// \[ matches the left bracket
// . any character except line breaks
// * 0 or more of the preceding character
// ? lazy matching
// \] matches the right bracket
$pattern = '/\[.*?\]/';
$replacement = '';
$subject = "The Bhagavad Gita presents a synthesis[5][6] of Hindu ideas about dharma,[5][6][7] theistic bhakti,[8][7] and the yogic paths to moksha.[6] The synthesis presents four paths to spirituality.";
$limit = -1;
$count = 0;
$result = preg_replace ($pattern, $replacement, $subject, $limit, $count);
?>
应该回来
《博伽梵歌》综合了印度教关于佛法、有神论巴克提和瑜伽修行的思想。合成提供了四条通往灵性的道路。因此,它并不意味着是一种代码编写服务。让我们看看你试过什么。阅读上的指南。你能澄清你的问题吗?是否要查找上标字符并将其替换为空格?(如果创建这样的函数,可能会意外删除预期的文本?)。还有,php标记是否必要?可能重复yes?我想查找上标字符并用空格替换