我有一個結果字符串像下面從另一字符串中提取字符串兩個特定字符
*WTY: this is Amy's home .
%mor: pro:dem|this cop|be&3s n:prop|Amy's n|home .
%snd: <00:00:00><00:01:23>
%WTY: this is Amy’s home . errfr ::: |
*WTY: last Sunday the television was showing the news report .
%mor: adj|last n:prop|Sunday det|the n|television aux|be&PAST v|showing det|the n|news n|report .
%snd: <00:01:77><00:06:65>
*WTY: the dog come back again and play with Amy .
%mor: det|the n|dog v|come adv|back adv|again conj|and v|play prep|with n:prop|Amy .
%snd: <01:06:70><01:12:85>
%WTY: {and} * (1.38) and_pfp (0.56) the dog (0.40) come back again err_m_s ::: and play with (0.56) Amy . err_m_s ::: |
我想extact一審「*」的詞與詞之間(asterik)和「:」(分號),如這裏的結果應該是「WTY」。我已經嘗試過下面的方法,但不能按預期工作。
var ID=result.split('*').pop().split(':').shift();
任何人都可以請指出錯誤或任何其他更好的解決方案?
你不想使用正則表達式? – Mahi
RegExp會很好,但我無法使用RegExp來完成它,我想要得到star的第一個實例,然後在該開始和冒號 –
之間的字符串,你只能使用正則表達式來解決這個問題。平原js不會幫你 – Mahi