{"size": 1034, "ext": "scrbl", "max_stars_repo_path": "lens-doc/unstable/lens/string-split.scrbl", "max_stars_repo_name": "AlexKnauth/lens", "max_stars_repo_stars_event_min_datetime": "2015-07-08T12:56:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T21:21:54.000Z", "max_issues_repo_path": "lens-doc/unstable/lens/string-split.scrbl", "max_issues_repo_name": "AlexKnauth/lens", "max_issues_repo_issues_event_min_datetime": "2015-07-07T01:47:59.000Z", "max_issues_repo_issues_event_max_datetime": "2019-09-10T18:35:17.000Z", "max_forks_repo_path": "lens-doc/unstable/lens/string-split.scrbl", "max_forks_repo_name": "AlexKnauth/lens", "max_forks_repo_forks_event_min_datetime": "2015-07-07T05:01:29.000Z", "max_forks_repo_forks_event_max_datetime": "2019-07-16T00:37:04.000Z"}
{"max_stars_count": 66, "max_issues_count": 199, "max_forks_count": 11, "avg_line_length": 41.36, "max_line_length": 79, "alphanum_fraction": 0.6808510638}
#lang scribble/manual

@(require lens/private/doc-util/main)

@title{Splitting Strings}

@defproc[(string-split-lens [sep (or/c string? char? regexp?)]) lens?]{
Creates a lens that splits a string into multiple pieces like
@racket[regexp-split] or @racket[string-split].
@lens-unstable-examples[
  (lens-view (string-split-lens ",") "a,b,c")
  (lens-set (string-split-lens ",") "a,b,c" '("1" "2" "3"))
]
Lenses created by @racket[string-split-lens] do not trim strings first, so that
when viewing a target that either starts or ends with something matching
@racket[sep], the view will include empty strings as the first or last element,
which is consistant with @racket[regexp-split] or @racket[string-split] with
@racket[#:trim? #f]. This is also more useful when using @racket[lens-set].
@lens-unstable-examples[
  (lens-view (string-split-lens ",") ",b,c")
  (lens-set (string-split-lens ",") ",b,c" '("a" "b" "c"))
  (lens-view (string-split-lens ",") "a,b,c,")
  (lens-set (string-split-lens ",") "a,b,c," '("a" "b" "c" "d"))
]}
