I am trying to regex all lightbox wordpress shortcodes and receive their 'link' attribute.
Example:
[lightbox link="http://www.test.com/photo1.jpg" width="150" align="none" title="photo 1" frame="true" icon="image"]
[lightbox link="http://www.test.com/photo2.jpg" width="150" align="none" title="photo 2" frame="true" icon="image"]
...
[lightbox link="http://www.test.com/photo5.jpg" width="150" align="none" title="photo 5" frame="true" icon="image"]
There can be any number of these shortcodes but I need to get all their link attributes:
http://www.test.com/photo1.jpg
My pattern I am working with:
$pattern = '/\[(\[?)(lightbox)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/';