【发布时间】:2022-01-19 07:32:51
【问题描述】:
字符串输入:
“12个苹果,3个橙子,10个葡萄”
解决方案:
let arr= inputString.split(" ");
要解决的问题:
我将如何与不是数字的任何东西分开?
字符串示例:
-
没有空格
12apples,3oranges,10grapes
-
()中的数字-
there are some (12) digits 5566 in this 770 string 239(我只想要 12、5566、770、239)
-
-
对它们进行数学运算的数字串
-
33+22(应该分成33和22)
-
我认为可行的方法:
arr= inputString.split("isNaN");
【问题讨论】:
-
为什么需要拆分?似乎您想要做完全相反的操作并 匹配 只有数字的项目。
标签: javascript split