Reputation: 460
I have the following (working) regex:
UNUSED([^,}]+)\}|,\s?UNUSED([^{]+)|UNUSED([^{]+),\s?|UNUSED([^{]+)
I run the command
sed 's/UNUSED([^,}]+)\}|,\s?UNUSED([^{]+)|UNUSED([^{]+),\s?|UNUSED([^{]+)//g' < index.css > newfile
but the newfile still has all the patterns in which should have been removed. What I am doing wrong?
index.css incl. regex:
Upvotes: 1
Views: 50
Reputation: 158100
Your are using an extended POSIX regex. You you need to pass -r
to sed to tell it to use extended POSIX regexes.
Also note that the capturing groups you are using can be omitted:
s/UNUSED[^,}]+}|,\s?UNUSED[^{]+|UNUSED[^{]+,\s?|UNUSED[^{]+//g
Of course you can also use a basic POSIX regex, then without the -n
option:
s/UNUSED[^,}]\+}\|,\s?UNUSED[^{]\+\|UNUSED[^{]\+,\s?\|UNUSED[^{]\+//g
Upvotes: 5