How to replace a string while while keeping a part of it using regex in Notepad++

前端 未结 1 1648
自闭症患者
自闭症患者 2021-01-24 16:35

I have file with multiple records: for example:

\"datetime\": \"2018-10-10\"
\"datetime\": \"2018-10-11\"
\"datetime\": \"2019-01-11\"
\"datetime\": \"2018-02-1         


        
1条回答
  •  不思量自难忘°
    2021-01-24 16:53

    You may use

    Find what: ("datetime": )(".*")
    Replace with: \1date\(\2\)

    Details

    • ("datetime": ) - Group 1 (\1 in the replacement pattern): a literal "datetime": substring
    • (".*") - Group 2 (\2 in the replacement pattern): ", any 0+ chars other than line break chars, as many as possible, and then a " (note that in case your contents are mixed, it is much safer to use a non-greedy pattern here, ".*?")

    Note that ( and ) inside the replacement pattern must be escaped as Notepad++ regex replacement patterns are Boost conditional replacement patterns and parentheses are "special" there.

    0 讨论(0)
提交回复
热议问题