Functions

String Functions

String manipulation and transformation methods available in kScript v2.0 for text processing.

Usage

String methods are called directly on string values using JavaScript-style method syntax. They behave exactly like standard JavaScript string methods.

var symbol = "BTC-USDT"
var parts = symbol.split("-")  // ["BTC", "USDT"]

var text = "hello world"
var upper = text.toUpperCase()  // "HELLO WORLD"

var str = "btc-usdt";
var str2 = " too high";
print(str.concat(str2));
// outputs "btc-usdt too high"

Available Methods

MethodCategorySignatureDescription
splitTransformationstr.split(separator)Splits a string into an array of substrings using a separator
concatTransformationstr.concat(...strings)Concatenates multiple strings together into a single string
substringTransformationstr.substring(start, end?)Extracts a portion of the string between two indices
toUpperCaseTransformationstr.toUpperCase()Converts all characters in the string to uppercase
toLowerCaseTransformationstr.toLowerCase()Converts all characters in the string to lowercase
trimTransformationstr.trim()Removes whitespace from both ends of the string
replaceTransformationstr.replace(search, replaceWith)Replaces the first occurrence of a search string with a replacement string
indexOfInspectionstr.indexOf(searchValue)Returns the index of the first occurrence of a substring (-1 if not found)
startsWithInspectionstr.startsWith(prefix)Checks if the string starts with the specified prefix
endsWithInspectionstr.endsWith(suffix)Checks if the string ends with the specified suffix
lengthInspectionstr.length()Returns the number of characters in the string