0
我有可能有任何的經歷通過
通過教師
發行所
這些話如何匹配從幾個字符序列之一開始的子字符串?
對於用戶
字之間的終結是一段字符串。因此,完整的字符串可能看起來像這樣
var string = 'Publish By: John Rellin. Subjected By: [email protected]';
,也可能是這樣
var string = 'Publish By: John Rellin. Subjected By: [email protected] By Teacher: Jason Alexander';
,或者可以是另一種變體
我想看看是否有任何的這些話在字符串。如果有published by
,我想,在比賽像match[1]
這將是Published By: John Rellin
等
我很新的正則表達式,並試圖此
string.match(/(Published By:|Subjected By|By Teacher|For user)/);
但沒有產生,我是結果希望。
我不知道如何實現這一點。我閱讀了一些文件,但無法找到與我正在尋找的東西很接近的東西。 任何幫助將不勝感激