my $rxSpaces = qr{(?x) # Use regex extended syntax to allow comments (?: # Open non-capturing group for alternation (?<= \A ) \s+ # Spaces preceded by beginning of string | # or (?<= \s ) \s+ # Spaces preceded by a single space | # or \s+ (?= \z ) # Spaces followed by end of string ) # Close group };