Re: how would you match this?

2016-10-17 Thread nfb
On Sun, Oct 16, 2016 at 05:47:01PM -0400, Jon LaBadie wrote:
> I played around with your sequence and confirmed your observation.
> Changing the quotes from double to single quotes seems to get
> what you are looking for.
> 
> Again that would go along with preserving backslashes during one
> round of evaluation.  In a double quoted string parsed by the shell,
> depending on the following character, a backslash may be escaping the
> next character or may be literal.  Using single quotes removes the
> ambiguity and makes them literal irrespective of the next char.

Hi Jon,
thank you for your time. Indeed using single quotes solves the issue.
But i couldn't imagine such a simple regex would have lead to this
problem. I'll pay extra attention in the future buiding the patterns.
Thanks again.


Re: how would you match this?

2016-10-16 Thread Jon LaBadie
On Sun, Oct 16, 2016 at 10:29:09PM +0200, nfb wrote:
> > It looks to me as if a second round of evaluation is being done.
> > During the first round the "\"s would be removed leaving "[[0-9]+]".
> > 
> > The second round would pair the first "[" with the first "]", the
> > one before the "+" and would make your character class be digits
> > or opening square bracket.  The final square bracket would be literal.
> > 
> > You may have to play with the number of backslashes, probably doubling
> > them though in some troff documents it was even necessary to tripling
> > them in order to have one preserved when it was needed.
> 
> Thank you, your explanation is plausible... I indeed already tried
> with some escaping before posting. I'll try harder.
> But in any case, doesn't it sound like a bug? Because a correct
> regular expression is not matching as it should.
> Thanks again.

I played around with your sequence and confirmed your observation.
Changing the quotes from double to single quotes seems to get
what you are looking for.

Again that would go along with preserving backslashes during one
round of evaluation.  In a double quoted string parsed by the shell,
depending on the following character, a backslash may be escaping the
next character or may be literal.  Using single quotes removes the
ambiguity and makes them literal irrespective of the next char.

Jon
-- 
Jon H. LaBadie j...@jgcomp.com
 11226 South Shore Rd.  (703) 787-0688 (H)
 Reston, VA  20190  (703) 935-6720 (C)


Re: how would you match this?

2016-10-16 Thread nfb
> It looks to me as if a second round of evaluation is being done.
> During the first round the "\"s would be removed leaving "[[0-9]+]".
> 
> The second round would pair the first "[" with the first "]", the
> one before the "+" and would make your character class be digits
> or opening square bracket.  The final square bracket would be literal.
> 
> You may have to play with the number of backslashes, probably doubling
> them though in some troff documents it was even necessary to tripling
> them in order to have one preserved when it was needed.

Thank you, your explanation is plausible... I indeed already tried
with some escaping before posting. I'll try harder.
But in any case, doesn't it sound like a bug? Because a correct
regular expression is not matching as it should.
Thanks again.


Re: how would you match this?

2016-10-16 Thread Jon LaBadie
On Sun, Oct 16, 2016 at 05:58:27PM +0200, nfb wrote:
> Hi,
> maybe this is a general and basic question about regex, but i also
> tried on regex101.com and it really should work...
> In my body i'd like to color URL indexes in the form [$ANYNUMBER], so
> in my muttrc i set a line like this:
> 
> color body brightmagenta default "\[[0-9]+\]"
> 
> Now, strings like:
> 
> [1]
> [123]
> etc.
> 
> are matched, and this is what i want, but it seems it also matches
> something like:
> 
> 123]
> :123]
> 12:123]
> 
> What am i doning wrong?

It looks to me as if a second round of evaluation is being done.
During the first round the "\"s would be removed leaving "[[0-9]+]".

The second round would pair the first "[" with the first "]", the
one before the "+" and would make your character class be digits
or opening square bracket.  The final square bracket would be literal.

You may have to play with the number of backslashes, probably doubling
them though in some troff documents it was even necessary to tripling
them in order to have one preserved when it was needed.

Jon
-- 
Jon H. LaBadie j...@jgcomp.com
 11226 South Shore Rd.  (703) 787-0688 (H)
 Reston, VA  20190  (703) 935-6720 (C)


how would you match this?

2016-10-16 Thread nfb
Hi,
maybe this is a general and basic question about regex, but i also
tried on regex101.com and it really should work...
In my body i'd like to color URL indexes in the form [$ANYNUMBER], so
in my muttrc i set a line like this:

color body brightmagenta default "\[[0-9]+\]"

Now, strings like:

[1]
[123]
etc.

are matched, and this is what i want, but it seems it also matches
something like:

123]
:123]
12:123]

What am i doning wrong?
Thank you.