<<< Date Index >>>     <<< Thread Index >>>

Re: highlighting urls ???



On 2004-01-10, Michael D Schleif <mds@xxxxxxxxxxx> wrote:
> OK, I have this URL:
> 
>    http://support.microsoft.com/default.aspx?scid=kb;[LN];Q260371
> 
> I have been using this in ~/.muttrc:
> 
>    color body brightblue default (https?|ftp)://[\-\.\,=/%~_:?\#a-zA-Z0-9&+]+
> 
> I am having problems adding the square brackets `[]' to that regexp.
> 
> Interestingly enough, the following only highlights `N]' and *not* `[L':
> 
>    color body brightred default [a-zA-Z0-9\[\]]+
> 
> Other attempts to escape `\[' and `\]' result in errors at mutt startup,
> and *NO* highlighting at all.
> 
> What do you think?

>From the mutt manual, under "Regular Expressions":

  A list of characters enclosed by ``['' and ``]'' matches any single
  character in that list; if the first character of the list is a caret
  ``^'' then it matches any character not in the list.  For example, the
  regular expression [0123456789] matches any single digit.  A range of
  ASCII characters may be specified by giving the first and last
  characters, separated by a hyphen ``-''.  Most metacharacters lose
  their special meaning inside lists.  To include a literal ``]'' place
  it first in the list.  Similarly, to include a literal ``^'' place it
  anywhere but first.  Finally, to include a literal hyphen ``-'' place
  it last.

So for your simple example, I think this will work:

  color body brightred default [][a-zA-Z0-9]+

HTH,
Gary

-- 
Gary Johnson                               | Agilent Technologies
garyjohn@xxxxxxxxxxxxxxx                   | Wireless Division
http://www.spocom.com/users/gjohnson/mutt/ | Spokane, Washington, USA