I'm pretty new to regular expression. Just tried to analyse a "BB-Code" that could do something like this:
Pattern:
\[element title=(.*)picture=(\d+)](.*)(?:\[caption](.*):?\[/caption])?\[/caption].*
Search:
[element title=element title picture=32]Lorem ipsum dolor[caption]Photo by John Doe[/caption][/element]
[element title=element title picture=32]Lorem ipsum dolor[/element]
Well, the caption-part should be optional and both entries should give results. How can I reach this?