Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: newbie parsing question

From: brett:codeconscious at: 4-Mar-2001 14:59

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