* Word Boundary problem with regex
@ 2005-06-05 22:24 Tim Johnson
0 siblings, 0 replies; 4+ messages in thread
From: Tim Johnson @ 2005-06-05 22:24 UTC (permalink / raw)
In case of word wrapping the text between (but not including) the lines
of asterisks should be on one line:
I am using the following expression
*******************************************************************************
\\([^][ \t\r\n{}()]+\\):[ ]*\\(d\\(ef\\|oes\\)\\|func\\(tion\\)\\|has\\|sub?\\)
*******************************************************************************
To colorize the following words: "def" "does" "func" "function" "has"
"sub" - which define subroutines.
When I type the following: test: def[val][print val], "def" is
colorized properly. One would exect that adding a letter to "def" would
turn off the target color, but does not. This suggests to me that
I have not properly defined the word boundary in the expression above.
Can anyone tell me what I am doing wrong?
FYI: This is for the rebol programming language (www.rebol.com), it
should be noted that in lispish fashion, a subroutine is an
expression, not an immutable control structure.
thanks
tim
--
Tim Johnson <tim@johnsons-web.com>
http://www.alaska-internet-solutions.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Word Boundary problem with regex
[not found] <mailman.3412.1118010266.25862.help-gnu-emacs@gnu.org>
@ 2005-06-05 22:55 ` Pascal Bourguignon
2005-06-06 8:37 ` Tim X
1 sibling, 0 replies; 4+ messages in thread
From: Pascal Bourguignon @ 2005-06-05 22:55 UTC (permalink / raw)
Tim Johnson <tim@johnsons-web.com> writes:
> In case of word wrapping the text between (but not including) the lines
> of asterisks should be on one line:
>
> I am using the following expression
> *******************************************************************************
> \\([^][ \t\r\n{}()]+\\):[ ]*\\(d\\(ef\\|oes\\)\\|func\\(tion\\)\\|has\\|sub?\\)
> *******************************************************************************
>
> To colorize the following words: "def" "does" "func" "function" "has"
> "sub" - which define subroutines.
>
> When I type the following: test: def[val][print val], "def" is
> colorized properly. One would exect that adding a letter to "def" would
> turn off the target color, but does not. This suggests to me that
> I have not properly defined the word boundary in the expression above.
>
> Can anyone tell me what I am doing wrong?
>
> FYI: This is for the rebol programming language (www.rebol.com), it
> should be noted that in lispish fashion, a subroutine is an
> expression, not an immutable control structure.
Just add "\\>" at the end.
You don't need "\\<" at the beginning since you're matching spaces and
special characters.
--
__Pascal Bourguignon__ http://www.informatimago.com/
Until real software engineering is developed, the next best practice
is to develop with a dynamic system that has extreme late binding in
all aspects. The first system to really do this in an important way
is Lisp. -- Alan Kay
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Word Boundary problem with regex
[not found] <mailman.3412.1118010266.25862.help-gnu-emacs@gnu.org>
2005-06-05 22:55 ` Word Boundary problem with regex Pascal Bourguignon
@ 2005-06-06 8:37 ` Tim X
2005-06-06 16:56 ` Tim Johnson
1 sibling, 1 reply; 4+ messages in thread
From: Tim X @ 2005-06-06 8:37 UTC (permalink / raw)
Tim Johnson <tim@johnsons-web.com> writes:
> In case of word wrapping the text between (but not including) the lines
> of asterisks should be on one line:
>
> I am using the following expression
> *******************************************************************************
> \\([^][ \t\r\n{}()]+\\):[ ]*\\(d\\(ef\\|oes\\)\\|func\\(tion\\)\\|has\\|sub?\\)
> *******************************************************************************
>
> To colorize the following words: "def" "does" "func" "function" "has"
> "sub" - which define subroutines.
>
> When I type the following: test: def[val][print val], "def" is
> colorized properly. One would exect that adding a letter to "def" would
> turn off the target color, but does not. This suggests to me that
> I have not properly defined the word boundary in the expression above.
>
> Can anyone tell me what I am doing wrong?
>
> FYI: This is for the rebol programming language (www.rebol.com), it
> should be noted that in lispish fashion, a subroutine is an
> expression, not an immutable control structure.
>
> thanks
> tim
>
> --
> Tim Johnson <tim@johnsons-web.com>
> http://www.alaska-internet-solutions.com
I'm not entirely clear on exactly what it is your trying to match, but
would recommend having a look at regexp-opt as it is particularly
useful for defining regexp for font-locking. A reasonably clear
example of its use can be found in sql.el - the sql-mode which comes
bundled with emacs.
HTH
Tim
,----[ C-h f regexp-opt RET ]
| regexp-opt is a compiled Lisp function in `regexp-opt'.
| (regexp-opt STRINGS &optional PAREN)
|
| Return a regexp to match a string in STRINGS.
| Each string should be unique in STRINGS and should not contain any regexps,
| quoted or not. If optional PAREN is non-nil, ensure that the returned regexp
| is enclosed by at least one regexp grouping construct.
| The returned regexp is typically more efficient than the equivalent regexp:
|
| (let ((open (if PAREN "\\(" "")) (close (if PAREN "\\)" "")))
| (concat open (mapconcat 'regexp-quote STRINGS "\\|") close))
|
| If PAREN is `words', then the resulting regexp is additionally surrounded
| by \< and \>.
`----
--
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you
really need to send mail, you should be able to work it out!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Word Boundary problem with regex
2005-06-06 8:37 ` Tim X
@ 2005-06-06 16:56 ` Tim Johnson
0 siblings, 0 replies; 4+ messages in thread
From: Tim Johnson @ 2005-06-06 16:56 UTC (permalink / raw)
* Tim X <timx@spamto.devnul.com> [050606 01:22]:
>
> I'm not entirely clear on exactly what it is your trying to match, but
> would recommend having a look at regexp-opt as it is particularly
> useful for defining regexp for font-locking. A reasonably clear
> example of its use can be found in sql.el - the sql-mode which comes
> bundled with emacs.
>
> HTH
>
> Tim
>
> ,----[ C-h f regexp-opt RET ]
> | regexp-opt is a compiled Lisp function in `regexp-opt'.
> | (regexp-opt STRINGS &optional PAREN)
> |
> | Return a regexp to match a string in STRINGS.
> | Each string should be unique in STRINGS and should not contain any regexps,
> | quoted or not. If optional PAREN is non-nil, ensure that the returned regexp
> | is enclosed by at least one regexp grouping construct.
> | The returned regexp is typically more efficient than the equivalent regexp:
> |
> | (let ((open (if PAREN "\\(" "")) (close (if PAREN "\\)" "")))
> | (concat open (mapconcat 'regexp-quote STRINGS "\\|") close))
> |
> | If PAREN is `words', then the resulting regexp is additionally surrounded
> | by \< and \>.
> `----
Thanks Tim (see the reply to this thread from Pascal)
Your tip on using regexp-opt will be very helpful for
this regex noob.
cheers
tim
--
Tim Johnson <tim@johnsons-web.com>
http://www.alaska-internet-solutions.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-06-06 16:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.3412.1118010266.25862.help-gnu-emacs@gnu.org>
2005-06-05 22:55 ` Word Boundary problem with regex Pascal Bourguignon
2005-06-06 8:37 ` Tim X
2005-06-06 16:56 ` Tim Johnson
2005-06-05 22:24 Tim Johnson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).