We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const str = ` 1 21 3 4 5 6 7 8 9 `; /* 多行字符串要用反引号 */ var arr = str.split('\n'); /* 根据换行符分割 */
The text was updated successfully, but these errors were encountered:
const str = ` 1 21 3 4 5 6 7 8 9 `; /* 多行字符串要用反引号 */ var arr = str.split("\n"); /* 根据换行符分割 */ const res = []; for (const subarr of arr) { let line = subarr.split(" ").filter((e) => e !== " " && e !== ''); res.push(line); } console.log(res);
Sorry, something went wrong.
const arr = str.split('\n'); /* 根据换行符分割 */ const res = []; for (const subarr of arr) { let line = subarr.trim().split(/\s+/g) res.push(line); } console.log(res);
var str = `line1 part1 part2 line2 part1 part2 line3 part1 part2`; var arr = str.split('\n').map(function(line) { return line..trim().split(/\s+/g); }); console.log(arr);
No branches or pull requests
The text was updated successfully, but these errors were encountered: