惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
G
Google Developers Blog
小众软件
小众软件
V
V2EX
月光博客
月光博客
腾讯CDC
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
Y
Y Combinator Blog
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 【当耐特】
D
Docker
M
MIT News - Artificial intelligence
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
InfoQ
MongoDB | Blog
MongoDB | Blog
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI

博客园 - ^Mao^

不同缩放下适配 vxe-table 3D饼图 openlayer实现给线的附近添加点,点支持移动 element-plus el-select html导出pdf openlayers增加移动功能 适配 部分页面统计用户访问时长 openlayers基本使用(街景+标注+绘制) 使用openlayer绘制街景地图 vue2实现el-table-column多级效果 echarts-雷达图 echarts--地图 散点图效果 echarts散点图区域设置 vant 的vant-uploader组件问题 Threejs学习 Echarts-普通地图和3D地图实现 test
正则表达式--取对应表达式的值
^Mao^ · 2025-07-01 · via 博客园 - ^Mao^

背景

有的时候我们需要在一个很长的字符串中取出对应的数值。我们可以利用正则表达式的分组

示例

<script>
  var str = '目标值(10),实际值(35)'
  // 第一个"\("表示普通的左括号,第二个"("表示第一个分组开始
  const reg = /目标值\((\d{0,3})\),实际值\((\d{0,3})\)/
  const target_val = str.replace(reg, '$1')
  const actual_val = str.replace(reg, '$2')
  console.log('target_val===>', target_val)
  console.log('actual_val===>', actual_val)
</script>

效果图:
image