Delete all lines with pipe symbol

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Billykid
Posts: 98
Joined: 16 Sep 2019, 08:59

Delete all lines with pipe symbol

25 Apr 2024, 07:27

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."
User avatar
mikeyww
Posts: 27127
Joined: 09 Sep 2014, 18:38

Re: Delete all lines with pipe symbol

25 Apr 2024, 08:12

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")

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: norot41087, peter_ahk and 107 guests