[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX-devel] Regex best practice
From: |
Arash Esbati |
Subject: |
Re: [AUCTeX-devel] Regex best practice |
Date: |
Sat, 28 Nov 2015 18:10:01 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 |
Mosè Giordano <address@hidden> writes:
> 2015-11-24 21:13 GMT+01:00 Arash Esbati <address@hidden>:
>>
>> Mosè Giordano <address@hidden> writes:
>>
>>> Probably yes: so you want to match the whole \declaretheoremstyle
>>> macro, but saving only the mandatory argument, right?
>>
>> Yes, exactly.
>
> The problem of your regex is that will match *everything* until the
> last closing bracket. This is good when you test your regex in a
> simple case, but will fail in a real document with other commands
> taking optional and mandatory arguments.
Thanks for your response. Your are right, I missed that completely.
> Is the non paired "]" in
>
> anothername = {valu-es[]}]{} ,
>
> intended?
No, it was just part of the experiment.
> If so, I don't have a solution at hand, otherwise, if you're sure you
> have always paired brackets, you can use something like
>
>
> "\\\\declaresomething\\[\\(?:[^][]*\\(?:\\[[^][]*\\(?:\\[[^][]*\\(?:\\[[^][]*\\][^][]*\\)*\\][^][]*\\)*\\][^][]*\\)*\\)\\][
> \t\n\r]*{[ \t\n\r]*\\(.*\\)[ \t\n\r]*}"
The existence of brackets is not guaranteed, it is the optional
argument. I will play around with your suggestion; I have to decode it
first ;-)
Best, Arash