I'm trying to write a regex replace to be run on a line containing a newline and I want the newline character to not be replaced. It seems like \s is matching the newline character, and I have no idea why or how to prevent that. I'm not using '$' or '.' in my regex, so I am not using a 'm' or 's' modifier. Any ideas?
Example script:
#!/usr/bin/perl use strict; use warnings; my $line = "Hi\n"; print length($line) . "\n"; $line =~ s/Hi\s*//; print length($line) . "\n";
Output I get:
I'm running v5.18.2 if it matters.3 0
In reply to \s matches newline in regex? by Only1KW
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |