Thank you! I'm looking at it, and don't fully understand it. [^\]]+ must mean to find everything inbetween?
Explanation: find every character one or more time EXCEPT right square bracket.
. doesn't match paragraph marks. You tried to use (.+\r.+)+ to get around that, but that's not going to work. There are two easy ways to get around that. One method is the one Marijan used: [^+ continues matching up to the next [, no matter what characters intervene, so it skips paragraph breaks. [^x] (where 'x' stands for any chancter) is a negative character class, so that [^x]+ can be read as 'while not x'.
The second method is to tell grep to treat the whole story as a single line:
where .+? stands for 'shortest match'.
This is great I've been using this
Couple of thing though more for my sanity then anything else...
If whetever is inbetween () is a copied then why is it that (?s) is ignored but the $1, and only replaces with the second instance of () which I would have thought would have been $2
Also This Grep falls over if there is a Table in the paragraph, is there a way to to ignore the table as I would have thought the table would be treated as text
There are various so-called non-capturing modifiers: (?s), (?i), etc. And even capturing parentheses can be made non-capturing if you just want to group something. E.g. (this|that)? captures all this and that, but if you want to test for the presence of this or that without any need to capture any of them, you use (?:this|that)?
Tables are a problem, they're one of those things that . doesn't match. Footnotes are another one, though you can get around them somehow. Tables appear to be an absolute break. Please file a bug against that at http://www.adobe.com/misc/bugreport.html