Reputation: 389
I have a $content variable which is a long string that contains the word "title" multiple times. How do I match title and print all of the matches in Bash regex?
[[ $content =~ title ]] && echo ${BASH_REMATCH}
This only prints the first match.
Upvotes: 0
Views: 900
Reputation: 2258
Can you give us the value of $content and also your desired output? It sounds like you need to do something like:
echo ${BASH_REMATCH[*]}
Upvotes: 1