How can I make a regex that would extract the the contents of the first square brackets in the following?
Block[first_name][value]
returns the string first_name
.
Block[last_name][value]
returns the string last_name
.
What I've tried:
This was my current regex: http://regex101.com/r/jW0hY1/1
/(?:Block\[).*(?:\[value])/
I figured first I'd have a non-capturing match for Block[
. Then I would capture all the content until ][value]
began. Instead this seems to return the entire string.