https://github.com/canop/splitty
A Rust string splitter taking quotes into account
https://github.com/canop/splitty
Last synced: over 1 year ago
JSON representation
A Rust string splitter taking quotes into account
- Host: GitHub
- URL: https://github.com/canop/splitty
- Owner: Canop
- License: mit
- Created: 2020-12-18T11:18:13.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-08-03T16:26:10.000Z (almost 2 years ago)
- Last Synced: 2025-04-15T00:05:23.811Z (over 1 year ago)
- Language: Rust
- Size: 5.86 KB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![MIT][s2]][l2] [![Latest Version][s1]][l1] [![docs][s3]][l3] [![Chat on Miaou][s4]][l4]
[s1]: https://img.shields.io/crates/v/splitty.svg
[l1]: https://crates.io/crates/splitty
[s2]: https://img.shields.io/badge/license-MIT-blue.svg
[l2]: LICENSE
[s3]: https://docs.rs/splitty/badge.svg
[l3]: https://docs.rs/splitty/
[s4]: https://miaou.dystroy.org/static/shields/room.svg
[l4]: https://miaou.dystroy.org/3
# splitty
A no-std string splitter for which spaces between quotes aren't separators.
Quotes not starting or ending a substring are handled as ordinary characters.
```rust
use splitty::*;
let cmd = "xterm -e \"vi /some/path\"";
let mut token = split_unquoted_char(cmd, ' ')
.unwrap_quotes(true);
assert_eq!(token.next(), Some("xterm"));
assert_eq!(token.next(), Some("-e"));
assert_eq!(token.next(), Some("vi /some/path"));
```