Str
CommandMiscellaneous
str {operation} {text} [parameters...]- Sets
#StrRes
Also searchable as: Str · string · text · substring · length
str works on a piece of text and puts the result in #StrRes.
| Operation | Result in #StrRes |
|---|---|
str len {text} |
The number of characters. |
str pos {text} {part} [n] |
Where part starts in text, counting from 1; with n, where its n-th occurrence starts. 0 when it is not there. |
str count {text} {part} |
How many times part occurs in text. |
str left {text} {n} |
The first n characters. |
str right {text} {n} |
The last n characters. |
str mid {text} {start} {n} |
n characters starting at character start. |
str lower {text} |
The text in lower case. |
str upper {text} |
The text in upper case. |
str ins {text} {part} {start} |
The text with part inserted at character start. |
str del {text} {start} {n} |
The text with n characters removed, starting at character start. |
pos and count ignore case. When parameters are missing, #StrRes is N/A.
Examples
Section titled “Examples”set %s HELLOstr len %s ; 5str pos %s LL ; 3str left %s 4 ; HELLstr right %s 2 ; LOstr mid %s 2 3 ; ELLstr lower %s ; hellostr upper hello ; HELLOstr ins %s I 3 ; HEILLOstr del %s 3 2 ; HEOstr count %s L ; 2display ok #StrReshaltSplit a text at _, using count and the occurrence parameter of pos:
set %test _this_is_a_test_str count %test _set %parts #StrRes - 1for %n 1 %parts{ str pos %test _ %n set %from #StrRes + 1 set %next %n + 1 str pos %test _ %next set %len #StrRes - %from str mid %test %from %len display ok #StrRes}haltSee also
Based on the EasyUO wiki, edited for EasyUO Reforged. This text is available under the GNU Free Documentation License 1.2.