RegEx, replace anything in-between and including []

Hi guys,

Using wordpress and shortcodes, and a custom written function to print post excerpts.

Unfortunately when using the shortcodes early in a post these becomes visible in the excerpt.

Got a few versions of shortcodes:

[single]
[startandend] [/startandend]
[singlewith id=“5”]

I’'ve manage to sucesfully found and replace the 1st and 2nd ones with the following regex:

|\(.+?)\?|s

…but the 3rd version with the ID in it is still there.

Any help and pointers on how to include the 3rd version of the shortcodes also would be great! :smiley:

Thanks!