Hello, Neil Jerram <neiljer...@gmail.com> writes:
> On Fri, 1 Mar 2019 at 08:14, Nicolas Goaziou <m...@nicolasgoaziou.fr> wrote: >> The regexp for bracket links could be, in its simple (!) form: >> >> \[\[\(.*?[^\\]\(?:\\\)*\)\]\(?:\[\([^\000]+?\)\]\)?\] > > [then a bit later] >> Small update, in its string form now: >> >> >> "\\[\\[\\([^\000]*?[^\\]\\(\\\\\\\\\\)*\\)\\]\\(?:\\[\\([^\000]+?\\)\\]\\)?\\]" > > Is [^\000] the only (or best) way of saying "any character, including > newlines"? There is also "\(.\|\n\)", or "[[:ascii:][:nonascii:]]". > Could there be actual NUL characters in the document? Good question. I used [^\000] out of habit. You are right, "\(.\|\n\)" is more robust. So, the new challenger is: "\\[\\[\\(\\(?:.\\|\n\\)*?[^\\]\\(\\\\\\\\\\)*\\)\\]\\(?:\\[\\(\\(?:.\\|\n\\)+?\\)\\]\\)?\\]" Beautiful. The commented rx equivalent would be: (seq "[" ;; URI part: match group 1. "[" (group (*? anything) ;; Allow an even number of backslashes before the closing bracket. (not (any "\\")) (zero-or-more (group "\\\\"))) "]" ;; Description (optional): match group 2. (opt "[" (group (+? anything)) "]") "]") > \( # begin group 3 > ? # don't understand > :\[ # literal :[ [...] > but there's at least a ? that I don't understand, and I'm afraid I'm > not seeing how it's useful. \(?: ... \) is a shy group. > If you think it works, I'm happy to defer to your judgement on that! > Although I suggested the idea, I don't know Org nearly well enough to > be sure that I haven't missed problems; We are solving the problem with a regexp. What bad things could happen? ;) Regards, -- Nicolas Goaziou