3 Textual Data
3.1 Text Representations
(require (planet cce/scheme:7:1/text)) |
This module provides tools for manipulating and converting textual data.
3.1.1 Contracts and Predicates
| ||
|
Examples: |
> (text? "text") |
#t |
> (text? #"text") |
#t |
> (text? 'text) |
#t |
> (text? '#:text) |
#t |
> (text? #'"text") |
#t |
> (text? #'#"text") |
#t |
> (text? #'text) |
#t |
> (text? #'#:text) |
#t |
> (text? '(not text)) |
#f |
| ||
| ||
|
Examples: |
> (string-literal? #'"literal") |
#t |
> (string-literal? "not literal") |
#f |
> (bytes-literal? #'#"literal") |
#t |
> (bytes-literal? #"not literal") |
#f |
> (keyword-literal? #'#:literal) |
#t |
> (keyword-literal? '#:not-literal) |
#f |
3.1.2 Text Conversions and Concatenation
| |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
|
Examples: |
> (text->string #"concat" #'enate) |
"concatenate" |
> (text->bytes #:between "-" 'concat #'#:enate) |
#"concat-enate" |
> (text->symbol #:before "(" #:after ")" '#:concat #'"enate") |
'|(concatenate)| |
> (text->keyword #:before #'< #:between #'- #:after #'> "concat" #'#"enate") |
'#:<concat-enate> |
| |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
|
Examples: | |||
> (text->string-literal #"concat" #'enate) | |||
#<syntax "concatenate"> | |||
> (text->bytes-literal #:between "-" 'concat #'#:enate) | |||
#<syntax #"concat-enate"> | |||
| |||
#<syntax:4:0 |(concatenate)|> | |||
| |||
#<syntax:5:0 #:<concat-enate>> |
3.1.3 Text Comparisons
| |||
| |||
| |||
| |||
|
(text=? one two) = (string=? (text->string one) (text->string two)) |
(text<? one two) = (string<? (text->string one) (text->string two)) |
(text<=? one two) = (string<=? (text->string one) (text->string two)) |
(text>? one two) = (string>? (text->string one) (text->string two)) |
(text>=? one two) = (string>=? (text->string one) (text->string two)) |
Examples: |
> (text=? #"x" #'y) |
#f |
> (text<? #"x" #'y) |
#t |
> (text<=? #"x" #'y) |
#t |
> (text>? #"x" #'y) |
#f |
> (text>=? #"x" #'y) |
#f |
3.2 Regular Expressions
(require (planet cce/scheme:7:1/regexp)) |
This module provides tools for building strings which can be compiled to regular expressions. In particular, the constructors wrap their arguments in appropriate delimeters to prevent misparsing after concatenation.
| ||||||||||||||||||||||||||||
start : string? = "" | ||||||||||||||||||||||||||||
between : string? = "" | ||||||||||||||||||||||||||||
end : string? = "" | ||||||||||||||||||||||||||||
re : string? |
Examples: | |||||||
| |||||||
> (regexp-match-exact? re "(1,10,100)") | |||||||
#t | |||||||
> (regexp-match-exact? re "(1,10)") | |||||||
#f | |||||||
> (regexp-match-exact? re " ( 1 , 10 , 100 ) ") | |||||||
#f |
Examples: | ||
| ||
> (regexp-match-exact? re "123") | ||
#t | ||
> (regexp-match-exact? re "c") | ||
#t | ||
> (regexp-match-exact? re "12c") | ||
#f |
(regexp-maybe re ...+) → string? |
re : string? |
Examples: | ||
| ||
> (regexp-match-exact? re "123.456") | ||
#t | ||
> (regexp-match-exact? re "") | ||
#t | ||
> (regexp-match-exact? re "123") | ||
#f |
(regexp-star re ...+) → string? |
re : string? |
Examples: | ||
| ||
> (regexp-match-exact? re "") | ||
#t | ||
> (regexp-match-exact? re "abc") | ||
#t | ||
> (regexp-match-exact? re "abcabcabc") | ||
#t | ||
> (regexp-match-exact? re "a") | ||
#f |
(regexp-plus re ...+) → string? |
re : string? |
Examples: | ||
| ||
> (regexp-match-exact? re "") | ||
#f | ||
> (regexp-match-exact? re "abc") | ||
#t | ||
> (regexp-match-exact? re "abcabcabc") | ||
#t | ||
> (regexp-match-exact? re "a") | ||
#f |
(regexp-save re ...+) → string? |
re : string? |
Examples: | |||
| |||
> (regexp-match-exact? re "11") | |||
#t | |||
> (regexp-match-exact? re "123123") | |||
#t | |||
> (regexp-match-exact? re "123456") | |||
#f |
(regexp-multi re ...+) → string? |
re : string? |
Examples: | ||
| ||
> (regexp-match? re "abc") | ||
#t | ||
> (regexp-match? re "xyz\nabc\ndef") | ||
#t |
3.3 XML and CSS
(require (planet cce/scheme:7:1/web)) |
This module provides tools for programmatic creation of static web pages. It is based on the XML collection; see documentation for xexpr?.
| ||
|
css | = | (list style ...) | ||
style-def | = | (cons selector (list property ...)) | ||
property | = | (list name value) | ||
selector | = | text | ||
name | = | text | ||
value | = | text |
Here, text is any of the Text Representations described above.
| |||
|
| |||
|