help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regex Problem => "overlapping words"


From: Tim Johnson
Subject: Re: Regex Problem => "overlapping words"
Date: Fri, 2 Dec 2005 11:56:14 -0900
User-agent: Mutt/1.4.2.1i

I may have solved it... Being a regex noob, I might not use all of the
appropriate wording here, but essentially, I has not defining the word
boundaries properly.

I arrived at what I think is the correct expression by evaluating the
following in *Scratch*:

(regexp-opt '("def" "does" "func" "function" "has" "sub"))
;; which gave me
"d\\(?:ef\\|oes\\)\\|func\\(?:tion\\)?\\|has\\|sub"
;; and led me to change the form to:

************************************************************************************************************************************
'("\\([^][ \t\r\n{}()]+\\):[ 
]*\\(d\\(?:ef\\|oes\\)\\|func\\(?:tion\\)?\\|has\\|sub?\\)\\>" (1 prepend) (2 
font-lock-keyword-face))
************************************************************************************************************************************

Since I'm still pretty wet behind the ears with regex, I still welcome
any comments or suggestions should anyone find anything incorrect ....
thanks
tim

* Tim Johnson <tim@johnsons-web.com> [051202 10:45]:
> I have a regex problem: the form containing the regex should appear
> as one line between two lines of asterisks:
> ******************************************************************************************************************************
> '("\\([^][ \t\r\n{}()]+\\):[ 
> ]*\\(d\\(ef\\|oes\\)\\|func\\(tion\\)\\|has\\|sub?\\)\\>" (1 prepend) (2 
> font-lock-keyword-face))
> ******************************************************************************************************************************
> 
> The intent is that the following 'words': def, does, func, function,
> has, sub
> 
> Should be highlighted as per 'font-lock-keyword-face.
> 
> 'function' is *not* highlighted, so I have not handled
> the "overlapping" words properly. 
> 
> All others are displayed as intended
> 
> I hope that someone can show me what I have done wrong.
> thanks
> tim
> 
> -- 
> Tim Johnson <tim@johnsons-web.com>
>       http://www.alaska-internet-solutions.com
> 
> 
> _______________________________________________
> Help-gnu-emacs mailing list
> Help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

-- 
Tim Johnson <tim@johnsons-web.com>
      http://www.alaska-internet-solutions.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]