Home > Software design >  replace a partial substring in notepad
replace a partial substring in notepad

Time:07-08

I need to find a certain pattern in notepad and delete all of it. So the lines might be something like:

1,2,c(0,9,3),5,7,9,2
2,3,c(4,7,2),5,4,3,1

and I want to get back:

1,2,5,7,9,2
2,3,5,4,3,1

how should I do this? Thanks

CodePudding user response:

  1. Open the replace dialog
  2. Select the radio button for regular expressions
  3. Use the search pattern
^(.*?),c\(.*?\)(.*?$)
  1. Replace it by
$1$2

This should match your lines and the both capture groups capture the parts you want to keep. Then we replace by the content of the both capture groups $1$2

  • Related