# String Consumption

**URL:** <https://forums.swift.org/t/string-consumption/21907>\
**Category:** Discussion\
**Tags:** string\
**Created:** [March 22, 2019, 1:17am UTC](https://forums.swift.org/t/string-consumption/21907 "2019-03-22T01:17:57Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Michael\_Ilseman](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/michael_ilseman/32/44640_2.png) [@Michael\_Ilseman](https://forums.swift.org/u/Michael_Ilseman)\
**Post date:** [March 27, 2019, 1:30am UTC](https://forums.swift.org/t/string-consumption/21907/5 "2019-03-27T01:30:15Z")

</div>

Eat and peek could be pitched whenever. I wonder if we should do a closure-based `(Character) -> Bool` seek now, or invest more effort in a Pattern type. Find/replace/split is in a similar boat, and we want a Pattern that's useful for regexes, pegs, parser-combinators, etc.

Rust's [str::Pattern](https://doc.rust-lang.org/std/str/pattern/trait.Pattern.html) seems like a good start. I don't think we'd limit it to Strings, rather have it for all Collections. This would (I think) be distinct from the protocol used for destructuring value-binding-patterns.

---

_[View the full topic](https://forums.swift.org/t/string-consumption/21907)._
