Strings can be lexicographically
compared using the ==, !=, >,
<, >= and <= operators.
Strings can be concatenated using the + operator:
// Concatenate a username and an email domain'username'+'@domain.com'
Sub-strings can be accessed using the index operator [].
They can also be accessed using the range operator [i:j]. Note
that parameter j, the upper bound in the range operator, is
not inclusive.
// Check if the first character of a string is 'a'mystring[0]=='a'// Check if the string starts with 'abc'mystring[0:3]=='abc'
Boolean, integer, float, and null values can be converted into strings
using the string() function:
non-null rules.String A string representing the result of the replacement
operation. If no substrings matched the regular expression, the unmodified
original string is returned.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-06-18 UTC."],[],[],null,["# Interface: String\n\n[rules](/docs/reference/rules/rules).String\n===========================================\n\ninterface static\n\nPrimitive type representing a string value.\n\nStrings can be lexicographically\ncompared using the `==`, `!=`, `\u003e`,\n`\u003c`, `\u003e=` and `\u003c=` operators.\n\nStrings can be concatenated using the `+` operator: \n\n```scilab\n// Concatenate a username and an email domain\n'username' + '@domain.com'\n```\n\nSub-strings can be accessed using the index operator `[]`.\nThey can also be accessed using the range operator `[i:j]`. Note\nthat parameter `j`, the upper bound in the range operator, is\nnot inclusive. \n\n```scilab\n// Check if the first character of a string is 'a'\nmystring[0] == 'a'\n\n// Check if the string starts with 'abc'\nmystring[0:3] == 'abc'\n```\n\nBoolean, integer, float, and null values can be converted into strings\nusing the `string()` function: \n\n```text\nstring(true) == \"true\"\nstring(1) == \"1\"\nstring(2.0) == \"2.0\"\nstring(null) == \"null\"\n```\n\nMethods\n-------\n\n### lower\n\nlower() returns [rules.String](/docs/reference/rules/rules.String)\n\nReturns a lowercase version of the input string.\n\nReturns\n\n: `non-null `[rules.String](/docs/reference/rules/rules.String) the lowercase string.\n\n#### Example\n\n 'ABC'.lower() == 'abc'\n 'ABC123'.lower() == 'abc123'\n\n### matches\n\nmatches(re) returns [rules.Boolean](/docs/reference/rules/rules.Boolean)\n\nPerforms a regular expression match on the whole string.\n\n| #### Parameter ||\n|----|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| re | [rules.String](/docs/reference/rules/rules.String) A regular expression using [Google RE2 syntax](https://github.com/google/re2/wiki/Syntax). Value must not be null. |\n\nReturns\n\n: `non-null `[rules.Boolean](/docs/reference/rules/rules.Boolean) true if the whole string matches, false otherwise.\n\n#### Example\n\n 'user@domain.com'.matches('.*@domain[.]com') == true\n 'banana'.matches('.*@domain[.]com') == false\n\n### replace\n\nreplace(re, sub) returns [rules.String](/docs/reference/rules/rules.String)\n\nReplaces all occurrences of substrings matching a regular expression with a\nuser-supplied string.\n\n| #### Parameter ||\n|-----|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| re | [rules.String](/docs/reference/rules/rules.String) A regular expression using [Google RE2 syntax](https://github.com/google/re2/wiki/Syntax). Value must not be null. |\n| sub | [rules.String](/docs/reference/rules/rules.String) A string to substitute. Value must not be null. |\n\nReturns\n\n: `non-null `[rules.String](/docs/reference/rules/rules.String) A string representing the result of the replacement\n operation. If no substrings matched the regular expression, the unmodified\n original string is returned.\n\n#### Example\n\n 'banana'.replace(\"a\", \"o\") == 'bonono'\n 'banana'.replace(\"ana\", \"ee\") == 'beena'\n 'foo@test.com'.replace(\".\", \"-\") == '---------------' // '.' regex match all\n\n### size\n\nsize() returns [rules.Integer](/docs/reference/rules/rules.Integer)\n\nReturns the number of characters in the string.\n\nReturns\n\n: `non-null `[rules.Integer](/docs/reference/rules/rules.Integer) the number of characters.\n\n#### Example\n\n 'a'.size() == 1\n 'abc'.size() == 3\n\n### split\n\nsplit(re) returns [rules.List](/docs/reference/rules/rules.List)\n\nSplits a string according to a regular expression.\n\n| #### Parameter ||\n|----|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| re | [rules.String](/docs/reference/rules/rules.String) A regular expression using [Google RE2 syntax](https://github.com/google/re2/wiki/Syntax). Value must not be null. |\n\nReturns\n\n: `non-null `[rules.List](/docs/reference/rules/rules.List) a list of strings.\n\n#### Example\n\n 'a/b/c'.split('/') == ['a', 'b', 'c']\n\n### toUtf8\n\ntoUtf8() returns [rules.Bytes](/docs/reference/rules/rules.Bytes)\n\nReturns the UTF-8 byte encoding of a string.\n\nReturns\n\n: `non-null `[rules.Bytes](/docs/reference/rules/rules.Bytes) a Bytes sequence containing the UTF-8 encoded\n representation of the string.\n\n#### Example\n\n '**'.toUtf8() == b'\\x2A\\x2A'\n '€'.toUtf8() == b'\\xE2\\x82\\xAC'\n\n### trim\n\ntrim() returns [rules.String](/docs/reference/rules/rules.String)\n\nReturns a version of the string with leading and trailing spaces removed.\n\nReturns\n\n: `non-null `[rules.String](/docs/reference/rules/rules.String) the trimmed string.\n\n#### Example\n\n ' a '.trim() == 'a'\n 'b'.trim() == 'b'\n\n### upper\n\nupper() returns [rules.String](/docs/reference/rules/rules.String)\n\nReturns an uppercase version of the input string.\n\nReturns\n\n: `non-null `[rules.String](/docs/reference/rules/rules.String) the uppercase string.\n\n#### Example\n\n 'abc'.upper() == 'ABC'\n 'abc123'.upper() == 'ABC123'"]]