我有两种标签。需要将“ [”替换为“ <”。我尝试了str_replace,但无法正常工作。
第一个标签:
$x = '<break time="2000ms"/>';
$y = '[pause="1000ms"]';
echo str_replace(['[ pause =','[pause=','[ pause=','[pause ='],"<break time",trim($y));
第二个标签:
[pitch = "x-low"][endpitch]
转换为
<prosody pitch="x-low"></prosody>
先谢谢了。
........已更新......
$text = 'I am [pitch = "high"]Rudratosh Shastri[endpitch]. what is your name ? how are you? sorry [pause="3000"] i can not hear you ?[rate="-70.00%"] i still can\'t hear you[endrate] ? [rate="+50.00%"]why i can\'t hear you[endrate] ?';
echo $text = preg_replace("/\[pause.*\"(\w+)\".*\]/", '<break time="$1ms"/>', $text);
output: I am [pitch = "high"]Rudratosh Shastri[endpitch]. what is your name ? how are you? sorry <break time="3000ms"/> ?
休息时间标记后未得到输出。