Regex搜索字符串实例,然后删除某些字符
我希望我的正则表达式搜索字符串的所有实例,然后只从中删除特定字符 e、 g.删除所有Regex搜索字符串实例,然后删除某些字符,regex,Regex,我希望我的正则表达式搜索字符串的所有实例,然后只从中删除特定字符 e、 g.删除所有\如设置日期(\'2020-10-28')成为设置日期(“2020-10-28”) 但在我的内容中可能有多个此函数的实例需要更新,如 setDates(\"2020-10-28\") some additional content and text setDates(\"2020-10-23\") 应该成为 setDates("2020-10-28")
\
如设置日期(\'2020-10-28')
成为设置日期(“2020-10-28”)
但在我的内容中可能有多个此函数的实例需要更新,如
setDates(\"2020-10-28\") some additional content and text setDates(\"2020-10-23\")
应该成为
setDates("2020-10-28") some additional content and text setDates("2020-10-23")
到目前为止,我所管理的是
setDates\(*\)
,它匹配setDates()
,但不匹配其中的\
,捕获除双引号以外的所有内容,并替换为反向引用:
Find: \b(setDates\()\\(".*?)\\("\))
Replace: $1$2
看
解释
--------------------------------------------------------------------------------
\b the boundary between a word char (\w) and
something that is not a word char
--------------------------------------------------------------------------------
( group and capture to \1:
--------------------------------------------------------------------------------
setDates 'setDates'
--------------------------------------------------------------------------------
\( '('
--------------------------------------------------------------------------------
) end of \1
--------------------------------------------------------------------------------
\\ '\'
--------------------------------------------------------------------------------
( group and capture to \2:
--------------------------------------------------------------------------------
" '"'
--------------------------------------------------------------------------------
.*? any character except \n (0 or more times
(matching the least amount possible))
--------------------------------------------------------------------------------
) end of \2
--------------------------------------------------------------------------------
\\ '\'
--------------------------------------------------------------------------------
( group and capture to \3:
--------------------------------------------------------------------------------
" '"'
--------------------------------------------------------------------------------
\) ')'
--------------------------------------------------------------------------------
) end of \3