{"size": 4094, "ext": "scrbl", "max_stars_repo_path": "share/pkgs/compatibility-doc/mzlib/scribblings/string.scrbl", "max_stars_repo_name": "takikawa/racket-ppa", "max_stars_repo_stars_event_min_datetime": "2018-07-29T04:13:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-14T16:11:17.000Z", "max_issues_repo_path": "compatibility-doc/mzlib/scribblings/string.scrbl", "max_issues_repo_name": "NoahStoryM/compatibility", "max_issues_repo_issues_event_min_datetime": "2017-08-25T20:26:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T17:48:40.000Z", "max_forks_repo_path": "compatibility-doc/mzlib/scribblings/string.scrbl", "max_forks_repo_name": "NoahStoryM/compatibility", "max_forks_repo_forks_event_min_datetime": "2015-03-09T12:20:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-09T05:02:56.000Z"}
{"max_stars_count": 10, "max_issues_count": 15, "max_forks_count": 8, "avg_line_length": 34.4033613445, "max_line_length": 87, "alphanum_fraction": 0.6118710308}
#lang scribble/doc
@(require "common.rkt"
          (for-label mzlib/string
                     scheme/contract
                     (only-in scheme/base
                              regexp-try-match)))

@mzlib[#:mode title string]

@deprecated[@racketmodname[racket/base]]{
Also see @racketmodname[racket/string]
}

The @racketmodname[mzlib/string] library re-exports several functions
from @racketmodname[scheme/base]:

@racketblock[
real->decimal-string
regexp-quote
regexp-replace-quote
regexp-match*
regexp-match-positions*
regexp-match-peek-positions*
regexp-split
regexp-match-exact?
]

It also re-exports @racket[regexp-try-match] as
@racket[regexp-match/fail-without-reading].


@defproc[(glob->regexp [str (or/c string bytes?)?]
                       [hide-dots? any/c #t]
                       [case-sensitive? any/c (eq? (system-path-convention-type)'unix)]
                       [simple? any/c #f])
         (or/c regexp? byte-regexp?)]{

Produces a regexp for a an input ``glob pattern'' @racket[str].  A
glob pattern is one that matches @litchar{*} with any string,
@litchar{?} with a single character, and character ranges are the same
as in regexps (unless @racket[simple?] is true). In addition, the
resulting regexp does not match strings that begin with @litchar{.},
unless @racket[str] begins with @litchar{.} or @racket[hide-dots?] is
@racket[#f].  The resulting regexp can be used with string file names
to check the glob pattern.  If the glob pattern is provided as a byte
string, the result is a byte regexp.

The @racket[case-sensitive?] argument determines whether the resulting
regexp is case-sensitive.

If @racket[simple?] is true, then ranges with
@litchar{[}...@litchar{]} in @racket[str] are treated as literal
character sequences.}


@defproc[(string-lowercase! [str (and/c string? (not/c immutable?))]) void?]{

Destructively changes @racket[str] to contain only lowercase
characters.}


@defproc[(string-uppercase! [str (and/c string? (not/c immutable?))]) void?]{

Destructively changes @racket[str] to contain only uppercase
characters.}



@defproc[(eval-string [str (or/c string? bytes?)]
                      [err-handler (or/c false/c
                                         (any/c . -> . any/c)
                                         (-> any/c))
                                   #f])
         list?]{

Reads and evaluates S-expressions from @racket[str], returning results
for all of the expressions in the string. If any expression produces
multiple results, the results are spliced into the resulting list.  If
@racket[str] contains only whitespace and comments, an empty list is
returned, and if @racket[str] contains multiple expressions, the
result will be contain multiple values from all subexpressions.

The @racket[err-handler] argument can be:
@itemize[
@item{@racket[#f] (the default) which means that errors are not
      caught;}
@item{a one-argument procedure, which will be used with an exception
      (when an error occurs) and its result will be returned}
@item{a thunk, which will be used to produce a result.}
]}


@defproc[(expr->string [expr any/c]) string?]{

Prints @racket[expr] into a string and returns the string.}


@defproc[(read-from-string [str (or/c string? bytes?)]
                           [err-handler (or/c false/c
                                              (any/c . -> . any/c)
                                              (-> any/c))
                                        #f])
          any/c]{

Reads the first S-expression from @racket[str] and returns it.  The
@racket[err-handler] is as in @racket[eval-string].}


@defproc[(read-from-string-all [str (or/c string? bytes?)]
                               [err-handler (or/c false/c
                                                  (any/c . -> . any/c)
                                                  (-> any/c))
                                            #f])
          list?]{

Reads all S-expressions from the string (or byte string) @racket[str]
and returns them in a list.  The @racket[err-handler] is as in
@racket[eval-string].}
