Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 在node.js中匹配后跟下划线的特定字母表_Regex_Match_Nodes - Fatal编程技术网

Regex 在node.js中匹配后跟下划线的特定字母表

Regex 在node.js中匹配后跟下划线的特定字母表,regex,match,nodes,Regex,Match,Nodes,* 需要匹配所有包含_web或_mb的变量 * 这就是我所做的 正则表达式=/(web | mb)/g * * 使用上面提到的正则表达式得到了完美的结果。 1-*(web | mb)表示下划线后跟字母web或mb 2-|用于正则表达式或在正则表达式中,正则表达式需要放在圆括号内 最后的3-g代表全球 *你的问题是什么?你的正则表达式与网站管理员或嵌入式匹配,你确定要匹配它们吗? const paragraph = 'vendors/photographer/12342323123/photo

* 需要匹配所有包含_web或_mb的变量 *

  • 这就是我所做的 正则表达式=/(web | mb)/g *
* 使用上面提到的正则表达式得到了完美的结果。 1-*(web | mb)表示下划线后跟字母web或mb 2-|用于正则表达式或在正则表达式中,正则表达式需要放在圆括号内 最后的3-g代表全球
*

你的问题是什么?你的正则表达式与
网站管理员
嵌入式
匹配,你确定要匹配它们吗?
const paragraph = 'vendors/photographer/12342323123/photos/3213/sdf32sd3_mb.jpg';
or
const paragraph = 'vendors/photographer/12342323123/photos/3213/sdf32sd3_web.jpg';
const paragraph = 'vendors/photographer/12342323123/photos/3213/sdf32sd3_mb.jpg';
const regex = /_*(web|mb)/g;
const found = paragraph.match(regex);
if(found !=null){
  console.log("compress image");
}else{
  console.log("do not compress image");
}

console.log(found);