[英]Javascript: How to use a regular expression in a loop
I have a question. 我有个问题。 I want to build a regular expression in java script within a loop. 我想在循环中的Java脚本中构建一个正则表达式。 I have the string "hi!whats.up" and I want to select in the loop each substring ("hi!","whats","up"), with a regular expression. 我有字符串“ hi!whats.up”,我想在循环中选择带有正则表达式的每个子字符串(“ hi!”,“ whats”,“ up”)。
Thank you in advance. 先感谢您。
let [a, b, c] = 'hi!whats.up'.split (/[^\w]+/)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.