我需要按字符串!
(前后空格)和一个字符|
拆分字符串。如何通过两个正则表达式拆分字符串
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
正则表达式。