javascript - 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!
解决方案
const x = `ALPRAZOLAM XANAX ANXIETY F41.1
ALPRAZOLAM XANAX DEPRESSION F33.0`;
const y = x.split("\n").flatMap(el => el.split(" "));
console.log(y);
推荐阅读
- c# - RT Linux 中的 C# 硬实时线程?
- c# - Json用2个数组反序列化字符串
- opengl - GLSL 复杂错误:从 vec4 隐式转换为 vec3
- wpf - 如何绑定 WPF 窗口宽度和高度但仍正确使用 WindowStarupLocation?
- mysql - 查询:计算一个表中的参数在另一个表中不存在的次数
- python - 创建一个新变量,它是python中另一个变量的每周最小值/最大值
- javascript - 如何检测应该更新先前对象的属性?
- python - 去模糊图像
- android - 如何检查 ParseObject 是否包含数据库中的特定列(Parse Dashboard)?
- javascript - Gravity Form 按钮执行两个操作 - 提交表单和另一个 onclick 操作