[REBOL] using parse to extract indexed string
From: rchristiansen::pop::isdfa::sei-it::com at: 13-Nov-2000 14:16
Parsing problem:
1. I want to parse a string and verify a keyword exists.
2. I want to mark the keyword with an index value.
3. I want to return to the marked index value and parse out index
value 'x to index value ('x + 100)
How do I do this? I'm having trouble understanding the use of index.
Here is my search code thus far...
directory-contents: read %./
; --- GET LIST OF FILE NAMES WITH VALID EXTENSIONS FROM
HELP DIRECTORY ---
file-list: copy []
for file-grab 1 (length? directory-contents) 1 [
file-name: first directory-contents
file-ext: find/last file-name "."
if file-ext = %.html [
append file-list file-name
]
directory-contents: next directory-contents
]
; --- QUERY HELP FILES FOR KEYWORD ---
pages-with-keyword: copy []
help-file-titles: copy []
keyword-count: copy []
foreach help-file file-list [
file-contents: read help-file
if find file-contents cgi-input/keyword [
append pages-with-keyword help-file
parse file-contents [thru <TITLE> copy text to </TITLE>
(append help-file-titles text)]
keyword: cgi-input/keyword
count: 0
parse file-contents [any [thru keyword (count: count + 1)]]
append keyword-count count
]
]
Thanks.
-Ryan