javascript - Javascript 中用于分隔单词的正则表达式

标签 javascript regex

我需要将在文本区域中输入的文本转换为如下形式:

word1|word2|word3|word4|word5

我该怎么做?

最佳答案

假设用户像这样将文本输入文本区域:

word1|word2|word3|word4|word5

然后将其存储在变量字符串 userText 中,然后使用:

var textArray = userText.split('|');

关于javascript - Javascript 中用于分隔单词的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4010252/

相关文章:

javascript - Webpack 动态要求抛出错误

javascript - React Google map API initMap 不是函数,没有包

python - 通过正则表达式拆分字符串

java - 正则表达式捕获不成对的括号或圆括号

javascript - 正则表达式:匹配大于或等于 1001 的数字

javascript - 基于单选按钮的结账表单计算 - Laravel 5.2

javascript - document.execCommand 复制命令不起作用或其他解决方案?

regex - 如何判断 Perl 正则表达式模式中匹配的替代项?

regex - HTML 输入模式不起作用

javascript - 使用 django 在 JS 中获取和使用 python 嵌套列表