On Mon, Oct 30, 2017 at 05:26:33AM -0400, Steve Engledow wrote:
-------- Original Message -------- The first line is essentially random, the second line will be all the same character of a limited number of possibles (=, - and maybe a couple more). The lines can probably be required to be the same length but it would be nice if they didn't have to be. It would be OK to have multiple REs, one for each possible 'underline' character.
Context is everything. Why are you trying to do this with a regular expression and what implementation will you be using?
Something like /([-_=])\1{3,}/ will match the underline part (the rest is straightforward) in some implementations but not all allow you to use backrefs in the match.
/.{4,}\n([-_=])\1{3,}/ ought to match what you've described. Again... it depends ;)
It's in PHP (ugh they say!).
I'm writing a plugin for DokuWiki so that it will recognise RestructuredText style underlined headings. The one thing I don't like about DokuWiki syntax is the heading style:-
======Top Level Heading======
====Lesser Heading====
I find restructuredText much more natural (and understandable when reading the text):-
Top Level Heading =================
Lesser Heading --------------
I have come up with a rather cruder RE than yours:-
'(?U)^[^\n]*\n====*$'
Obviously only matches ==== underlines but the way that DokuWiki plugins work means I can add multiple matching RE patterns so I can just repeat the above for other characters.
In yours does the range [-_=] mean it will match a line like ==-___===?