# string match -r -v "c.*" dog can cat diz dog diz exit 0 # string match -q -r -v "c.*" dog can cat diz exit 0 # string match -v "c*" dog can cat diz dog diz exit 0 # string match -q -v "c*" dog can cat diz exit 0 # string match -v "d*" dog dan dat diz exit 1 # string match -q -v "d*" dog dan dat diz exit 1 # string match -r -v x y y exit 0 # string match -r -v x x exit 1 # string match -q -r -v x y exit 0 # string match -q -r -v x x exit 1 # string length "hello, world" 12 # string length -q "" zero length # string sub --length 2 abcde ab # string sub -s 2 -l 2 abcde bc # string sub --start=-2 abcde de # string split . example.com example com # string split -r -m1 / /usr/local/bin/fish /usr/local/bin fish # string split "" abc a b c # seq 3 | string join ... 1...2...3 # string trim " abc " abc # string trim --right --chars=yz xyzzy zany x zan # echo \x07 | string escape \cg # string match "?" a a # string match "a*b" axxb axxb # string match -i "a??B" Axxb Axxb # echo "ok?" | string match "*\?" ok? # string match -r "cat|dog|fish" "nice dog" dog # string match -r "(\d\d?):(\d\d):(\d\d)" 2:34:56 2:34:56 2 34 56 # string match -r "^(\w{2,4})\g1\$" papa mud murmur papa pa murmur mur # string match -r -a -n at ratatat 2 2 4 2 6 2 # string match -r -i "0x[0-9a-f]{1,8}" "int magic = 0xBadC0de;" 0xBadC0de # string replace is was "blue is my favorite" blue was my favorite # string replace 3rd last 1st 2nd 3rd 1st 2nd last # string replace -a " " _ "spaces to underscores" spaces_to_underscores # string replace -r -a "[^\d.]+" " " "0 one two 3.14 four 5x" 0 3.14 5 # string replace -r "(\w+)\s+(\w+)" "\$2 \$1 \$\$" "left right" right left $ # string replace -r "\s*newline\s*" "\n" "put a newline here" put a here # string replace -r -a "(\w)" "\$1\$1" ab aabb # string length missing argument returns 1 # string match -r -v "[dcantg].*" dog can cat diz no regexp invert match # string match -v "???" dog can cat diz no glob invert match # string match -rvn a bbb 1 3 # string repeat -n 2 "foo" foofoo # string repeat --count 2 "foo" foofoo # echo foo | string repeat -n 2 foofoo # string repeat -n2 -q "foo" exit 0 # string repeat -n2 --quiet "foo" exit 0 # string repeat -n0 "foo" exit 1 # string repeat -n0 exit 1 # string repeat -m0 exit 1 # string repeat -n1 -N "there is " there is no newline # string repeat -n1 --no-newline "there is " there is no newline # string repeat -n10 -m4 "foo" foof # string repeat -n10 --max 5 "foo" foofo # string repeat -n3 -m20 "foo" foofoofoo # string repeat -m4 "foo" foof # string repeat "" string repeat empty string failed # string repeat -n3 "" string repeat empty string failed # string match -f x abc dxf xyz jkx x z dxf xyz jkx x # string match x abc dxf xyz jkx x z x # string match --filter -r "a*b[xy]+" abc abxc bye aaabyz kaabxz abbxy abcx caabxyxz abxc bye aaabyz kaabxz abbxy caabxyxz # string match -r "a*b[xy]+" abc abxc bye aaabyz kaabxz abbxy abcx caabxyxz abx by aaaby aabx bxy aabxyx # string match --filter -r "a*b([xy]+)" abc abxc bye aaabyz kaabxz abbxy abcx caabxyxz abxc x bye y aaabyz y kaabxz x abbxy xy caabxyxz xyx # string match -r "a*b([xy]+)" abc abxc bye aaabyz kaabxz abbxy abcx caabxyxz abx x by y aaaby y aabx x bxy xy aabxyx xyx