I’ve made a WordPress plugin that uses JS to populate the excerpt textarea of the post edit form with the first few sentences of the post body in the “write post panel”. (I know WordPress shows the first 55 words as a default if there’s no excerpt – this is what my client wanted.) Unfortunately if there’s a shortcode in the post body this appears in my auto-excerpt. For example
[imageshortcode url="http://xxx.co.uk/i/pix/2012/04/12/article-1234237614713-128F6F6E000005DC-482208_636x407.jpg" title="Clock Tower" caption="A clock on top of a train station in Damascus"]
Does anybody know some jQuery wheeze I can use to strip out this kind of shortcode from the text I’m taking from the post editor?
In case this is useful for anybody else, I ended up using this JS regex to strip out any characters between square brackets from the text, while leaving any text that might’ve come beween shortcode tags, like [note] … [/note].