I want to extract filter rules configured in /etc/lvm/lvm.conf, like filter = [ \"r|/dev/sda|\" ]. I want sed to return \"r|/dev
/etc/lvm/lvm.conf
filter = [ \"r|/dev/sda|\" ]
sed
\"r|/dev
Alternatively easier and shorter than [^[:space:]] you can do with \S+ without using brackets []
[^[:space:]]
\S+
[]
\S means non whitespace char
\S
echo ' filter = [ "r|/dev/sda|" ] ' | sed -r 's:^\s*filter\s*=\s*\[\s*(\S+)\s*\]:\1:g'
https://ideone.com/PxDX1Q