- Go:
corefunc.StripCommentsAndSpaces(string)
- TF:
corefunc_strip_comments_and_spaces
Idea is to have something that can strip all comments and inner-whitespace from a long, multi-line string. The original use-case is for enabling users to wrap and comment things like regular expressions, then use this to strip all of that stuff back out before passing it to regex()
, regexall()
or replace()
in Terraform.
Regexes should use \s
to match spaces instead of using a literal ASCII=20 space character.
Supported comments begin with a #//
(space, octothorpe, slash, slash, space — making this up as I go along), and end with an LF
or CRLF
. This means that it will only support single-line, end-of-line comments.
The goal is not to validate or even execute the regex. The goal is simply compress it into a single line without whitespace or comments without messing it up, and without having to do list/join gymnastics.
Looking for examples both simple and gnarly.