Simple problem but I can't fix it.
I have the following perl regex:
echo ... | grep -P "(?i)(v(ersion)?)\s?(?!0)\d(\.|,)\d{1,}"
This is supposed to match every string that describes a version of something (e.g. V2,0 or version 1.2). But it doesn't match when the version starts with V0.... However, when I execute this, I get an error -bash: !0: event not found because !<string> is used to search through command history and execute the latest hit.
This basically breaks perl regex for me. How can I avoid the shell from interpreting it as a shortcut?
11 Answer
Use single quotes, not double quotes, to protect your regexp from the shell.