#split #quote #string

no-std splitty

a string splitter taking quotes into account

4 releases (stable)

1.0.2 Aug 3, 2024
1.0.1 Sep 24, 2022
1.0.0 Sep 23, 2022
0.1.0 Dec 18, 2020

#60 in Parser tooling

Download history 2703/week @ 2025-11-30 3035/week @ 2025-12-07 2834/week @ 2025-12-14 1601/week @ 2025-12-21 766/week @ 2025-12-28 2791/week @ 2026-01-04 3290/week @ 2026-01-11 3199/week @ 2026-01-18 3100/week @ 2026-01-25 2088/week @ 2026-02-01 2615/week @ 2026-02-08 3077/week @ 2026-02-15 8192/week @ 2026-02-22 6353/week @ 2026-03-01 5035/week @ 2026-03-08 5909/week @ 2026-03-15

25,824 downloads per month
Used in 19 crates (2 directly)

MIT license

9KB
120 lines

A no-std string splitter for which spaces between quotes aren't separators.

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"));
assert_eq!(token.next(), None);

Quotes not starting or ending a substring are handled as ordinary characters.

Splitty has a limited set of features but is tested for corner-cases:

use splitty::*;

let cmd = r#" a  "2 * 试" x"x "z "#;

let mut token = split_unquoted_whitespace(cmd)
    .unwrap_quotes(true);

assert_eq!(token.next(), Some("a"));
assert_eq!(token.next(), Some("2 * 试"));
assert_eq!(token.next(), Some("x\"x"));
assert_eq!(token.next(), Some("\"z "));
assert_eq!(token.next(), None);

MIT Latest Version docs Chat on Miaou

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.

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"));

No runtime deps