Regex to remove comment lines
Posted: 01 Jul 2019, 10:38
Code: Select all
Test =
(
; Foo
;Bar
; aaa aaaaa
Baz
)
Test := RegExReplace(Test, "???", "")
MsgBox % Test
Let's help each other out
https://www.autohotkey.com/boards/
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=65865
Code: Select all
Test =
(
; Foo
;Bar
; aaa aaaaa
Baz
)
Test := RegExReplace(Test, "???", "")
MsgBox % Test
Code: Select all
Test =
(
; Foo
;Bar
; aaa aaaaa
Baz
; last comment
)
Test := RegExReplace(Test, "`am)^\s*;.*(?:\R|$)")
MsgBox % "|" Test "|"
Code: Select all
Test =
(
; Foo
;Bar
; aaa aaaaa
Baz
; last comment
)
Test := RegExReplace(Test, "m`a)(\R)?^\s*;.*(?(1)|\R)")
MsgBox % "|" Test "|"