javascript - 正则表达式替换多个非空行
问题描述
因此,我需要将 js 文件作为字符串读取,并将 [] 中的任何内容替换为其他数据。
原来的
const array = [
'text_a',
'text_b',
];
并且输出需要是
const array = [
'replacing_text_a',
'replacing_text_b',
'replacing_text_c',
];
我尝试了很多东西,我得到的最接近的是
const[ ]{0,}array[ ]{0,}=[ ]{0,}\[([\s\S]{0,})];
但我明白了Unmatched ')'
解决方案
推荐阅读
- python - 如何在 Windows 10 中使用 python 读取 *.so 文件?
- python-3.x - 无法在 tkinter python 中更新文本
- jquery - 带有替换值的jQuery克隆div
- javascript - 如何从 cellEdited:function(cell) 获取行索引?- 制表符
- c++ - 将 R2R FFT 从 FFTW 移植到 cuFFT
- javascript - 如何在快递中将 TINYINT(1) 转换为 BOOLEAN?
- python - TypeError: name() 参数 1 必须是 unicode 字符,而不是 str python
- weblogic - 无法从找不到 Weblogic.Server 错误中启动 Weblogic
- vb.net - 组合框中的鼠标滚动事件
- python - Python Open CV & yolo 对象检测和跟踪