Target string:
Come to the castle [Mario], I’ve baked
you [a cake]
I want to match the contents of the last brackets, ignoring the other brackets ie
a cake
I’m a bit stuck, can anyone provide the answer?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This should do it:
\[([^[\]]*)]matches any sequence of[…]that does not contain[or];[^[]*matches any following characters that are not[(i.e. the begin of another potential group of[…]);(?:\[[^\]]*)?$matches a potential single[that is not followed by a closing].