I have a file input.txt with the following content:
foo
[assembly: AssemblyVersion("1.2.3")]
bar")]
quux
To match the 1.2.3
from the input the following script is used:
#!/bin/bash
regex='\[assembly: AssemblyVersion\("(.*)"\)\]'
fileContent=$(cat input.txt)
[[ "$fileContent" =~ $regex ]]
echo "${BASH_REMATCH[1]}"
I would expect the output to be 1.2.3
but it is:
1.2.3")]
bar
Why is that so? How to fix it?
The regular expressions tester at https://regex101.com works as expected.