REBOL [
Author: "Brett Handley"
Title: "Parser for special files."
Comment: "Example of parsing for John Sequeira"
]
ctx-special-file-parser: context [
desired-number: none ; Will be set by the parser.
a-char: charset [#"A" - #"Z" #"a" - #"z"] ; Parse rule to match characters.
a-digit: charset [#"0" - #"9"] ; Parse rule to match digits.
; Parse rule to match the filename structure.
; Will set the field desired-number
file-name-structure: [
(desired-number: none)
some a-char
some a-digit
#"s"
copy desired-number some a-digit
to end
]
set 'print-special-file-number func [
full-file-path [file!]
][
either parse second split-path full-file-path file-name-structure [
print desired-number
][print "parse failed"]
]
]
; Examples
print-special-file-number %/some-path/AAA00000s0.jpg
print-special-file-number %/some-path/Absdfpkj349874s12.jpg
print-special-file-number %/some-path/As0.jpg
----- Original Message -----
From: "John Sequeira" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, March 04, 2001 5:39 AM
Subject: [REBOL] newbie parsing question
> I've been wrestling unsuccessfully with the parsing dialect on the
following
> simple(?) problem.
>
> I've got an <IMG SRC=""> tag, and I'd like to parse the filename in the
SRC
> attribute.
> The format of the filename is : /some-path/AAA00000s0.jpg or
> /some-path/AAA00000s00.jpg where A is a character [A-Z], and 0
represents
> a digit. I want to grab the one or two digits following the 's'.
>
> In perl, this would be something like:
> $html =~ s/s([0-9]+)\.jpg/$1/
>
> I'm having a traumatic experience mapping this to REBOL. Any suggestions?
>
>
>
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.
>
--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.