Difference between revisions of "String"

From MiniScript Wiki
Jump to navigation Jump to search
(Created page with "<c>string</c> is one of the core Category:data types in MiniScript. Category:Language Category:Data Types {{stub}}")
 
(Completed methods)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<c>string</c> is one of the core [[:Category:data types]] in MiniScript.
+
<c>string</c> is one of the core [[:Category:Data Types|data types]] in MiniScript.
 +
 
 +
Strings in MiniScript are immutable. Because of this operations which would modify the string return a new one instead.
 +
 
 +
== Methods ==
 +
 
 +
{| class="wikitable"
 +
|-
 +
! Method !! Description
 +
|-
 +
| len || Returns the length of the string
 +
|-
 +
| indexOf(''substring'') || Returns the index of the first occurrence of ''substring'' in the string, or <c>null</c> if not found
 +
|-
 +
| remove(''substring'') || Returns a new string with the first occurrence of ''substring'' removed
 +
|-
 +
| insert(''index'', ''otherString'') || Returns a new string with ''otherString'' inserted at ''index''
 +
|-
 +
| replace(''substring'', ''otherString'', ''maxCount'') || Returns a new list replacing occurrences of ''substring'' with ''otherString'' at most ''maxCount'', if specified. If ''maxCount'' is omitted it replaces '''all''' occurrences.
 +
|-
 +
| split(''separator'') || Splits the string by a ''separator'' substring, returning a list of the split parts
 +
|-
 +
| lower || Returns a new string with all letter converted to ''lowercase''
 +
|-
 +
| upper || Returns a new string with all letter converted to ''uppercase''
 +
|-
 +
| code || Returns the numeric code of the first character of the string
 +
|-
 +
| val || Returns the numeric value represented by the string; returns <c>0</c> if the conversion is not possible
 +
|-
 +
| indexes || Returns a list with the indexes of the characters of the string
 +
|-
 +
| hasIndex(''index'') || Returns 1 (true) if the requested ''index'' is among the string's indexes, 0 otherwise
 +
|-
 +
| values || Returns a list with each individual character that make up the string
 +
|}
 +
 
 +
== See also ==
 +
* [[stringUtil]] - for additional operations on strings
  
 
[[Category:Language]]
 
[[Category:Language]]

Latest revision as of 12:22, 6 December 2021

string is one of the core data types in MiniScript.

Strings in MiniScript are immutable. Because of this operations which would modify the string return a new one instead.

Methods

Method Description
len Returns the length of the string
indexOf(substring) Returns the index of the first occurrence of substring in the string, or null if not found
remove(substring) Returns a new string with the first occurrence of substring removed
insert(index, otherString) Returns a new string with otherString inserted at index
replace(substring, otherString, maxCount) Returns a new list replacing occurrences of substring with otherString at most maxCount, if specified. If maxCount is omitted it replaces all occurrences.
split(separator) Splits the string by a separator substring, returning a list of the split parts
lower Returns a new string with all letter converted to lowercase
upper Returns a new string with all letter converted to uppercase
code Returns the numeric code of the first character of the string
val Returns the numeric value represented by the string; returns 0 if the conversion is not possible
indexes Returns a list with the indexes of the characters of the string
hasIndex(index) Returns 1 (true) if the requested index is among the string's indexes, 0 otherwise
values Returns a list with each individual character that make up the string

See also


This article is a stub. You can help the MiniScript Wiki by expanding it.