I am currently working on a project using jQuery and JavaScript. There will be several a elements within the DOM, and these can be grouped using the rel attribute, something like jqgal[mygal1].
Once one of the anchors is clicked, I want to extract the value between the squared brackets, and read it into a variable for use later in the script. So for example in the following markup:
<a href="my_image_1.jpg" rel="jqgal[mygal1]"><img src="some_image.jpg" /></a>
The RegularExpression should return mygal1. I have been trying to figure this out and so far haven’t turned up much (it’s been one of those days). Can anyone indicate the correct regular expression to perform this action? If it helps, the string outside of the brackets will always be jqgal[].
Something like this should help: