x str
High-performance string manipulation module providing rich string operations.
Supports case conversion, trim, split, replace, encoding/decoding, hash calculation, etc.
Low-level module, subcommand-level help not supported.
TIP
This is a low-level high-performance module, all TLDR examples are at root level.
Supports both pipe input and argument input.
Examples
Example: convert string to uppercase
x str upper helloExample: convert string to lowercase via pipe
echo "Hello World" | x str lowerExample: trim whitespace from both ends
x str trim " hello "Example: trim leading whitespace
x str triml " hello"Example: trim trailing whitespace
x str trimr "hello "Example: slice index 1 to 3 (result: bc)
x str slice abcdef 1:3Example: slice excluding last char (result: abcde)
x str slice abcdef 0:-1Example: slice excluding last 2 chars (result: abcd)
x str slice abcdef 0:-2Example: slice from index 2 to end (result: cdef)
x str slice abcdef 2:Example: slice from start to index 3 (result: abc)
x str slice abcdef :3Example: slice last 3 chars (result: def)
x str slice abcdef -3:Example: slice from -5 to -2 (result: bcd)
x str slice abcdef -5:-2Example: extract 3 chars from index 2, C-style (result: cde)
x str substr abcdef 2 3Example: split string by comma
x str split "," a,b,cExample: split string via pipe
echo "a,b,c" | x str split ","Example: replace first occurrence
x str replace "hello world" world bashExample: replace all occurrences
x str replace_all "a,b,a" a xExample: join strings with comma
x str join "," a b cExample: calculate string length
x str len helloExample: check if string starts with 'he'
x str startswith "hello" "he"Example: check if string ends with 'lo'
x str endswith "hello" "lo"Example: Base64 encode
x str base64 helloExample: Base64 decode
x str unbase64 aGVsbG8=Example: calculate MD5 hash
x str md5 helloExample: calculate SHA256 hash
x str sha256 helloExample: convert DOS to Unix line endings
x str dos2unix file.txtExample: convert Unix to DOS line endings
x str unix2dos file.txtExample: repeat character 10 times
x str repeat "*" 10Example: find substring index
x str indexof "hello world" worldSub Commands
| Name | Description |
|---|---|
| x str replace | Replace first occurrence of substring |
| x str replace_all | Replace all occurrences of substring |
| x str ml | Multi-line text processing (wrap, trim, etc.) |
| x str regex | Regular expression matching |
| x str upper | Convert string to uppercase |
| x str lower | Convert string to lowercase |
| x str trim | Remove whitespace from both ends |
| x str triml | Remove leading whitespace |
| x str trimr | Remove trailing whitespace |
| x str split | Split string by delimiter |
| x str md5 | Calculate MD5 hash |
| x str sha256 | Calculate SHA256 hash |
| x str base64 | Base64 encoding |
| x str unbase64 | Base64 decoding |
| x str join | Join strings with separator |
| x str len | Calculate string length |
| x str slice | Extract substring (0-based index). Two styles: - slice: Python-style with colon-separated start:end (e.g. 1:3, 0:-1), negative indices count from end - substr: C-style with start position and length (e.g. substr str 2 3) |
| x str indexof | Find the index of substring in string |
| x str startswith | Check if string starts with specified prefix |
| x str endswith | Check if string ends with specified suffix |
| x str repeat | Repeat string specified number of times |
| x str dos2unix | Convert DOS/Windows line endings to Unix |
| x str unix2dos | Convert Unix line endings to DOS/Windows |
| x str work | String batch processing framework |
TIP
In interactive terminal ( zsh, bash ... ), Can use Tab to get completion information
Run CMD SUBCOMMAND --help for more information on a command
This article author
Please indicate the source and link of this article when reprinting.
Help us make these docs great!
All X-CMD docs are generated from command help and multiple data sources. See something that's wrong or unclear? Feel free to let us know through any of these ways~