Closed Klustre closed 1 month ago
Try this way:
let regex = /^\/\/\/\s<reference.+\/>\n/;
text = text.replace(regex, "")
You need something like this for the line ending, though: (\r\n|\n|\r)
.
There's no need to make it more specific than necessary. The one you posted only works in a single case and fails when preceded by comments.
Triple-slash directives are only valid at the top of their containing file. A triple-slash directive can only be preceded by single or multi-line comments, including other triple-slash directives. If they are encountered following a statement or a declaration they are treated as regular single-line comments, and hold no special meaning. Source
Strip Typescript's Triple-Slash Directives from the code when using
Send to Cavalry As…
. They're only useful in VSCode and pollute Cavalry's expression editor.