in reply to Question regarding a regex

the characters -~ in the character class

Unless the hyphen is the very first character, it signifies a range. In this case, it's the range ' ' (space) through '~' (tilde) - which is essentially the entire range of printable ASCII characters.

So what this test is saying: is there a "line" of "text" - where "line" is defined by the ^ and $ anchors, and "text" is defined as "all the printable ASCII characters, plus the selected whitespace characters newline, carriage return, tab, and space."

Replies are listed 'Best First'.
Re^2: Question regarding a regex
by LanX (Saint) on Jul 22, 2021 at 20:55 UTC
    > Unless the hyphen is the very first character, it signifies a range.

    or the very last.

    DB<1> p '-' =~ /[a-]/ 1 DB<2> p '-' =~ /[a- ]/ Invalid [] range "a- " in re ..

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery