Page 1 of 1

find string, delete whole line ans replace with string only

Posted: Wed Dec 04, 2019 5:26 pm
by jbrady33
Hello:

what I am trying to do:
find: ^.*(string in middle of line)?$
replace (string in middle of line


real stuff - find string "SMTP:xxxxxxx@vbelcas.mail.onmicrosoft.com" and delete everyting else on line
find:
^.*($smtp:[a-z1-9]{7}@vbelcas.mail.onmicrosoft.com)?$
that works so far

the replace I can't get right
tried:
$1
/1
\g1
$&

what am I doing wrong?

Thank in advance!

Posted: Thu Dec 05, 2019 3:25 pm
by ben_josephs
And if it doesn't occur on a line do you want the result to be an empty line?

Try
Find what: .*(smtp:[a-z1-9]{7}@vbelcas\.mail\.onmicrosoft\.com).*\n|.+\n
Replace with: $1\n

Posted: Thu Dec 05, 2019 3:26 pm
by jbrady33
And I'm an idiot - had the wrong slash

should be \1