To delete anything other than a specific text, you need to use .*(text_you_need_to_keep).* corresponding to the new line.
In Notepad ++ use
Find :. .*(phone=\S*?digits=1).*
Replace : $1
NOTE :. matches the newline option .
Am I using \S*? instead of .* inside the capture template, since you only want to combine any characters without spaces as little as possible from phone= to the nearest digits . .* too greedy and can stretch over several lines with the DOTALL option.
UPDATE
If you want to save several multiple occurrences of a template in text, in Notepad ++, you can use
.*?(phone=\S*?digits=1)
Replace with $1\n . In this case, you will delete all unwanted substrings, except those that were after the last occurrence of your required subpattern.
You will need to remove the last fragment either manaully or
FIND: (phone=\S*?digits=1).* REPLACE: $1
source share