我需要按字符串!
(前後空格)和一個字符|
拆分字符串。如何通過兩個正則表達式拆分字符串
function split (str) {
return str.split (/\s!\s/)
}
result = split ("hello world ! hello | world! hi ");
console.log (result); // result must be: ["hello world", "hello", "world! hi "]
我不知道該怎麼做。現在我所做的只是通過!
進行分割。加字符|
需要進行篩選,因爲它意味着OR
正則表達式。