[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Regexp to find second of three words
From: |
Tim Johnson |
Subject: |
Re: Regexp to find second of three words |
Date: |
Tue, 08 Aug 2006 15:51:31 -0000 |
User-agent: |
slrn/0.9.8.0 (Linux) |
On 2006-08-07, Eric Hanchrow <offby1@blarg.net> wrote:
Hi Eric:
In rebol, which has some lispish features, subroutines are values, not
immutable parts of the language syntax. And can have different
rules (think pascal, => function vs. procedure)
And a subroutine can be created by the 'set function
as in
set 'printf def[ ; arguments
][;code here. variables are automatically local
]
or
set 'printf function[ ; arguments
][; local variable declared here and initialized to 'none
][;code here
]
I solved this after getting away from the computer for a while. :-)
(defconst rebol-find-set-function-regexp
(concat "set[ ]+'\\(\\<[A-Za-z0-9*-_.]+\\)[ ]\\("
;; ^ word boundary
rebol-function-names-regexp "\\)\\>")
"Regexp to find functions defined by the 'set function.")
;; by placing a word boundary before the character class
> I probably misunderstand what you're trying to do with the stuff that
> begins with \\(d\\(?:ef, but I imagine you'll be able to correct what
created by regexp-opt
> I've got.
>
> (let ((p (rx "set"
> (one-or-more space) "'" (group (one-or-more (or alnum (any
> "*-_."))))
> (one-or-more space) (or "def" "does" "func" "function" "has"
> "lfinc" "sub")))
> (input "set 'printf function"))
>
> (string-match p input)
> (match-string 1 input))
Very interesting. This is a very different approach. I will have to try to
absorb it. I think I am about to be enlighted.
Thanks very much for that example!
cheers
tim
--
Tim Johnson <tim@johnsons-web.com>
http://www.alaska-internet-solutions.com