首页 > 解决方案 > How to splice several strings

问题描述

Good evening, I am attempting to extract multiple variables in a line which is separated by tabs. Here is an example of the lines:

ALPRAZOLAM XANAX ANXIETY F41.1
ALPRAZOLAM XANAX DEPRESSION F33.0

How would one go about extracting the individual values from this line? Thank you!

标签: javascript

解决方案


const x = `ALPRAZOLAM XANAX ANXIETY F41.1
ALPRAZOLAM XANAX DEPRESSION F33.0`;

const y = x.split("\n").flatMap(el => el.split(" "));

console.log(y);


推荐阅读