Page 1 of 1

Delete all lines with pipe symbol

Posted: 25 Apr 2024, 07:27
by Billykid
I would like to use RegExReplace to delete all lines in a text that contain a pipe symbol |.
Thank you for your help.

Code: Select all

; Before:
str := "This is the first sentence`nThis is | the second sentence`nThis is the third sentence`nThis is the | fourth sentence.`nThis is the fifth sentence.`nSixth sentence."
; Result:
str := "This is the first sentence`nThis is the third sentence`nThis is the fifth sentence.`nSixth sentence."

Re: Delete all lines with pipe symbol

Posted: 25 Apr 2024, 08:12
by mikeyww

Code: Select all

#Requires AutoHotkey v1.1.33.11
str := "
(
This is the first sentence
This is | the second sentence
This is the third sentence
This is the | fourth sentence.
This is the fifth sentence.
Sixth sentence.
)"
MsgBox 64, Result, % Trim(RegExReplace(str, "m`a)^.*\|.*$\R?"), " `t`r`n")