Voca_rs is a Rust library for manipulating strings.
Voca_rs is inspired by Voca.js, string.py and Inflector
Voca_rs is implemented on Foreign Types, i.e. String
and str
.
Using functions:
use voca_rs::*;
let input_string = "LazyLoad with XMLHttpRequest and snake_case";
let string_in_words = split::words(&input_string);
// => ["Lazy", "Load", "with", "XML", "Http", "Request", "and", "snake", "case"]
let words_in_string = &string_in_words.join(" ");
// => "Lazy Load with XML Http Request and snake case"
let truncated_string = chop::prune(&words_in_string, 21, "");
// => "Lazy Load with XML..."
let sliced_string = chop::slice(&truncated_string, 5, -2);
// => "Load with XML."
let snaked_string = case::snake_case(&sliced_string);
// => "load_with_xml"
Using traits (all methods start from the underscore symbol):
use voca_rs::Voca;
"LazyLoad with XMLHttpRequest and snake_case"
._words()
// => ["Lazy", "Load", "with", "XML", "Http", "Request", "and", "snake", "case"]
.join(" ")
// => "Lazy Load with XML Http Request and snake case"
._prune(21, "")
// => "Lazy Load with XML..."
._slice(5, -2)
// => "Load with XML."
._snake_case();
// => "load_with_xml"
See the complete documentation at https://e1r0nd.github.io/voca_rs/
Run tests: cargo test
Build docs: cargo doc
-> ./target/doc/voca_rs/index.html
Build a project: cargo build
-> ./target/debug
- camel_case
- capitalize
- decapitalize
- kebab_case
- lower_case
- lower_first
- pascal_case
- shouty_kebab_case
- shouty_snake_case
- snake_case
- swap_case
- title_case
- train_case
- upper_case
- upper_first
- char_at
- code_point_at
- first
- foreign_key
- grapheme_at
- last
- max
- min
- prune
- slice
- substr
- substring
- truncate
- expand_spaces
- expand_tabs
- insert
- latinise
- pad
- pad_left
- pad_right
- repeat
- replace
- replace_all
- reverse
- reverse_grapheme
- slugify
- splice
- tr
- trim
- trim_left
- trim_right
- word_wrap
- zfill
- ends_with
- includes
- is_alpha
- is_alphadigit
- is_blank
- is_camel_case
- is_capitalize
- is_decapitalize
- is_digit
- is_empty
- is_foreign_key
- is_lowercase
- is_lower_first
- is_kebab_case
- is_shouty_kebab_case
- is_numeric
- is_pascal_case
- is_snake_case
- is_shouty_snake_case
- is_title
- is_train_case
- is_uppercase
- is_upper_first
- matches
- query
- starts_with
- ASCII_LETTERS
- ASCII_LOWERCASE
- ASCII_UPPERCASE
- DIGITS
- HEXDIGITS
- OCTDIGITS
- PUNCTUATION
- PRINTABLE
- WHITESPACE
- VERSION
- Possible refactoring: all
position
indexes covert to zero-based and add a comment to each doc - Change all inner arguments to Enums (instead
string
orbool
) - To ensure that all regexp expressions are wrapped by
lazy_static
- countWhere - link
- count_unique_words - link: Counting occurrences of words using a hash map that stores words and counts
- vprintf - link
- finish - link
- start - link
- deordinalize - link
- pluralize - link
- singularize - link
- ordinalize - link
coded by Anatol Marezhanyi @e1r0nd_crg
https://linkedin.com/in/merezhany/
https://www.youtube.com/c/AnatolMerezhanyi
Licensed under MIT License