I have a string and I want to match the content of double square brackets: Example:
<p><span>"Sed ut perspiciatis vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</span></p><p><span>[[image file="2013-12/5s_1.jpg" alt="IPhone 5s" title="IPhone 5s" ]]</span></p><p><span>[[download file="2013-12/modulo-per-restituzione-prodotti-.pdf" icon="icon" text="" title="Download" ]]</span></p>
Results:
download file="2013-12/module-res.pdf" icon="icon" text="" title="Download"
image file="2013-12/5s_1.jpg" alt="IPhone 5s" title="IPhone 5s"
Consider that these 2 strings can contain any type of characters, I tried this solution but I have problems with other characters:
\[\[[\w+\s*="-\/]*\]\]
What about using a negated character class
This class would match anything but "]"
See it here on Regexr
To avoid the square brackets beeing part of the result, you can either use a capturing group
and get the result from group 1
or use lookaround assertions (if it is supported by your regex engine)
See it on Regexr