【发布时间】:2011-09-25 02:45:13
【问题描述】:
我有这个 javascript 字符串:
"<!--:fr-->Photos<!--:--><!--:en-->Pictures<!--:-->"
我需要对其进行解析,以将每种“语言”都放在不同的字符串中。理想的功能是:
function getText(text, lang){
// get and return the string of the language "lang" inside the multilang string "text"
}
我可以这样称呼:
var frenchText = getText("<!--:fr-->Photos<!--:--><!--:en-->Pictures<!--:-->","fr");
// and would return:
// frenchText = Photos
如果有人知道这样做的好方法,可能使用一个非常棒的正则表达式!!!
【问题讨论】:
-
这个问题在这里用PHP回答,如果有人感兴趣的话:stackoverflow.com/questions/1853406/…
标签: javascript jquery wordpress qtranslate