細繩:(STR,0:30) + |“戶外”| + |“椅墊”、“商用地墊”、“門墊”| + [帖子類型] + (STR,0:30)結果:(STR,0:30) +“戶外”+ |“椅墊”、“商業地墊”、“門墊”| + [帖子類型] + (STR,0:30)我努力了preg_replace('/\|\"[a-z A-Z]\"\|/i', '"', $string);我無法找到任何解決方案,我知道的唯一條件是字符串將以|"和 結尾"|,如果它不包含","之間,我們可以刪除或替換|"和"|"
1 回答

叮當貓咪
TA貢獻1776條經驗 獲得超12個贊
我認為你可以使用這樣的正則表達式:
\|("[^,]+")\|
$re = '/\|("[^,]+")\|/m';
$str = '(STR,0:30) + |"Outdoor"| + |"Chair Mat","Commercial Floor Mat","Door Mat"| + [Post Type] + (STR,0:30)';
$subst = '$1';
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
// (STR,0:30) + "Outdoor" + |"Chair Mat","Commercial Floor Mat","Door Mat"| + [Post Type] + (STR,0:30)
分享
- 1 回答
- 0 關注
- 145 瀏覽
添加回答
舉報
0/150
提交
取消