我需要逐个字符串!(前后空格)和一个 char拆分字符串|。
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 "]
我不知道该怎么做。现在我所做的只是拆分!. 加上 char|需要筛选,因为它OR在正则表达式中的意思。