'Perl substitute to print everything not matched with regex [closed]
I am trying to print everything remaining that is not matched from my regex. I know the regex is good but not sure I understand the syntax correctly to execute it right. The print that I get is not at all what I have using regex101. Any ideas would be helpful. Trying to print the remaining context not matched and eventually out to another file but want to make sure I also understand the comment. Here is what I have...
perl -ne "print s/((0\.0\.0\.0)|(127\.0\.0\.1)|(\|\|)|(#.*)|(\^)|(\h))/m/gi;" a.txt
Solution 1:[1]
This works.
perl -pe "s/((0\.0\.0\.0)|(127\.0\.0\.1)|(\|\|)|(#.*)|(\^)|(\h))//gi;" a.txt
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | silverzpeed |
