VScode 正则查找和替换
VScode 查找和替换正则表达式转义字符整理
符号
需要在正则模式下使用
\n 换行
1. 属性替换:
替换所有 class 为 class=”kkk”
查找正则
\s
class=”(.*?
)”替换
空格
class=”kkk”
替换 import
替换 import
\{
xxxx\}
from ‘(.*?)
‘
**替换 console.log **
console.log(
(.*?)
)console.log(
.*
)
2. 标签属性替换技巧
比如要给 所以 el-input 加 clearable, 但是可能有些 el-input 有该属性,为了避免冲突,可以先全局清除 clearable 属性。然后再使用:
索引 <el-input
空格
替换为 <el-input
空格
clearable空格
3. 插入替换:
- 查找用正则,替换不需要使用正则,但可以使用
$index
匹配对应分组()
替换前
1 |
|
正则表达式写法
1 |
|
替换后的代码
1 |
|
普通 css 替换为 css **module**
1 |
|
4. 不包括:
1 |
|
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!