I don't think so. Did you test that notion? Suggestion: try moving the "\$" to the last position in the class.
See characters in a character-class in "Mastering Regular Expressions" and Friedl's explanation that character-class-metacharacters are NOT the same as metacharacters outside a character class (pp 9-10). He also alludes to the differences elsewhere in the text. Very little is interpolated inside a character class (with the obvious exceptions of the likes of "-" or an initial "^" negation).
However, returning to OP's conundrum: it does NOT appear to be quite as stated. Rather, it appears to me that "Hello there0" matches his posted regex, while removing the preceding "\" before the "$" causes it to fail.
Now, the distraction of a very nice summer day (one of very few, thusfar) discourages me from feeling that the following is an adequate answer, but /me thinks "hello there0" passes his regex because his regex does not include decimal digits (see my line 14).
However, I must admit, I don't understand why, when using my line 11 rather than 14, the output is as it is: "hello there0" is not okay, but "hello there$ now" is. Brighter minds; wiser heads, pray edify!
Update: graff has. See his correct analysis below and everybody's above. Apologies to everybody and to OP. Balance of this post allowed to stand for whatever value (as an object lesson in incomplete testing/analysis) it may have.
#!/usr/bin/perl use strict; use warnings; # 783199 my @data = <DATA>; for my $line (@data) { chomp $line; # if ( $line =~ /[<>@#\$%^&*()_+=|\{\}\[\]\/\\]/ ) { # OP's char + class ie "escaped the $ sign" # if ( $line =~ /[<>@#%^&*()_+=|\{\}\[\]\/\\]\$/ ) { # OP's char + class ie "escaped the $ sign" with \$ moved to end of class # if ( $line =~ /[<>@#$%^&*()_+=|\{\}\[\]\/\\]/) { # $ sign no +t backslashed # if ( $line =~ /[<>@#\$%^&*()_+=|{}\]\/\\]/ ) { # unnecessa +ry backslashes removed if ( $line =~ /[0-9<>@#\$%^&*()_+=|{}[\]\/\\]/ ) { # rul +e out decimal digits print "\$line: $line \t is not okay \n"; }else { print "\$line: $line \t is okay \n"; } } =head $ sign in char class preceded by a backslash $line: hello there0 is okay $line: hello there is okay $line: hello there$ now is not okay $line: hello there $ now is not okay $line: hello there [ is not okay $line: by [rights] this should fail. is not okay $ sign in char class NOT preceded by a backslash $line: hello there0 is not okay $line: hello there is okay $line: hello there$ now is okay $line: hello there $ now is okay $line: hello there [ is not okay $line: by [rights] this should fail. is not okay Unnecessary backslashes removed: $line: hello there0 is okay $line: hello there is okay $line: hello there$ now is not okay $line: hello there $ now is not okay $line: hello there [ is okay $line: by [rights] this should fail. is not okay and with Decimal Digits rejected: $line: hello there0 is not okay $line: hello there is okay $line: hello there$ now is not okay $line: hello there $ now is not okay $line: hello there [ is not okay $line: by [rights] this should fail. is not okay =cut __DATA__ hello there0 hello there hello there$ now hello there $ now hello there [ by [rights] this should fail.
In reply to Re^2: Regex help
by ww
in thread Regex help
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |