Score:0

when using ?! in perl regex, bash interprets it as search through command history

in flag
Cas

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?

hr flag
Somewhat related: [bash: error in export command that bash: !st: event not found](https://askubuntu.com/questions/1130809/bash-error-in-export-command-that-bash-st-event-not-found)
Score:1
es flag

Use single quotes, not double quotes, to protect your regexp from the shell.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.