[plt-scheme] v299 and pattern matching filenames

From: Ron Stanonik (stanonik at Cogsci.ucsd.edu)
Date: Tue Nov 9 13:15:27 EST 2004

On Tue, 9 Nov 2004, Robby Findler wrote:
> You should use path->bytes and byte regexps, in this case. Use
> path->string to display the strings to the user, but otherwise try to
> avoid it (because not all paths can be turned into strings anymore).
> 
> path->bytes and bytes->path, on the other hand (modulo some windows
> issues that may even be worked out by now) don't lose any information.

Thanks.  Let me see if I understand.  Starting with a path and pattern,
I convert the path and the pattern to byte strings, and then convert the
pattern byte string to a byte-regexp.

  (set! bpath (path->bytes path))
  (set! bpattern (string->bytes/utf-8 pattern))
  (set! brexp (byte-regexp bpattern))

Perform the match 

  (regexp-match brexp bpath)

Then convert any result byte strings that interest me back to paths

  (set! rpath (bytes->path bresult))

or strings

  (set! spath (bytes->string/utf-8 bresult))

Correct?

Thanks,

Ron
stanonik at cogsci.ucsd.edu



Posted on the users mailing list.