- DESCRIPTION
- PROPERTIES
- data : Array<<Char>>
- The array of characters that comprise the string.
- Invariant: never altered outside of initializers.
- hash_code : Int32
- Returns the hash_code of this String. See Object::hash_code().Int32 for more details.
- METHODS
- init(Char ch)
- Creates a String of count==1 containing the single Char 'ch'.
- init(Int32 len)
- Creates a String of null characters. Used with 'substring'.
- init(Array<<Char>> init:data)
- Creates a string that directly uses the given character array. Caution: changing the character array after the string is created will change the string contents!
- init(StringBuilder buffer)
- Turns the content of the given StringBuilder into a single String.
- init(Readable<<Char>> src)
- init(Reader<<Char>> src)
- Creates a String out of all the characters in 'src'.
- create_duplicate().String
- Returns this same String object since strings are immutable.
- consolidate().String
- set_hash_code() : native
- hash_code().Int32
- Returns the hash_code of this String.
- data().Array<<Char>>
- Enforces the immutable property of strings by throwing an error on any attempt to access this string's data.
- to_String().String
- Returns this String object unmodified.
- count().Int32
- Returns the number of characters (0 or more) in this string.
- get(Int32 i).Char
- Retrieves the character at index i.
- Requires: 0 <= i < count
- set(Int32 i,Char value)
- Sets the character at index 'i'.
- Requires: 0 <= i < count
- op==(Object other).Logical {multimethod}
- Compares this string to another object.
- Returns false if 'other' is not a string, or forwards the call to String::op==(String) otherwise.
- op==(String other).Logical : native {multimethod}
- Compares this string to another string.
- Returns:
"false" if (this.hash_code != other.hash_code)
or (this.count != other.count)
"true" if all characters match between 'this' and 'other'.
f (this is other) return true f (&hash_code != other.&hash_code) return false eturn op<>( other ) == eq
- equals_ignore_case(String other).Logical
- Returns true if this string is equal to another string, ignoring the case of characters during comparison.
- For example, "ABcd".equals_ignore_case("AbCd") returns "true".
- op<>(Object other).Logical {multimethod}
- op<>(String other).Logical : native {multimethod}
- matches(Pattern p).Logical
- matches_wildcard_pattern(String wildcard_pattern).Logical
- Determines whether or not this string matches the given Unix/Dos-style "wildcard pattern". 'wildcard_pattern' is a regular text string that may contain the following special characters:
-
* - matches zero or more characters of this string.
? - matches any one character of this string.
Example:
local String st = "img_01.png"
println( st.matches_wildcard_pattern("*.png") ) # true
println( st.matches_wildcard_pattern("img_??.png") ) # true
- op+(String other).String
- Returns a new string consisting of 'this' concatenated with 'other'.
- Requires: other isNot null
- op+(Char ch).String
- Returns a new string consisting of 'this' concatenated with 'ch'.
- op+(Int64 n).String
- Returns a new string consisting of 'this' concatenated with a base 10 string representation of 'n'.
- op+(Int32 n).String
- Returns a new string consisting of 'this' concatenated with a base 10 string representation of 'n'.
- op+(Real64 n).String
- Returns a new string consisting of 'this' concatenated with a base 10 string representation of 'n'.
- op+(Logical n).String
- Returns a new string consisting of 'this' concatenated with string representation of 'n'.
- op+(Object obj).String
- Adds the string representation of the given object to this string and returns the joined string.
- substring(Int32 first_index).String
- Returns the subsequence of characters from this[first_index] up to the end of the string.
- Requires:
0 <= first_index < count
- get(Range<<Int32>> range).String
- get(Readable<<Int32>> range).String
- Returns the substring of characters specified by the given 'Readable<<Int32>>' range of indices.
- extract_groups(Pattern p).String[]
- extract_all_groups(Pattern p).String[]
- index_of(String other[,Int32 starting_index]).Int32
- last_index_of(String other[,Int32 starting_index]).Int32
- Returns the last (rightmost) occurrence of the 'other' string within this string. An optional starting index may be passed as the second parameter. If it's omitted, it is assumed to be 'count - 1'.
- Returns the leftmost index of the match or -1 if there's no match.
- Example:
println( "abab".last_index_of("ab") ) # prints: 2
println( "abab".last_index_of("ab",2) ) # prints: 2
println( "abab".last_index_of("ab",1) ) # prints: 0
println( "abab".last_index_of("zz") ) # prints: -1
- index_of(Pattern p[,Int32 starting_index]).Int32
- Finds the first occurrence of the given pattern within this string, with an optional starting index (default: 0).
- Returns (result >= 0) if found or (-1) if not found.
- begins_with(String st).Logical
- Returns "true" if this string begins with the given substring or false otherwise.
- starts_with(String st).Logical
- OBSOLETE as of v0.21. Use begins_with() instead.
- ends_with(String st).Logical
- Returns "true" if this string ends with the given substring or false otherwise.
- contains(String other).Logical
- Returns "true" if this string contains the given string as a subsequence.
- replace(Char look_for,Char replace_with).String
- Replaces all instances of character 'look_for' with character 'replace_with'.
- replace(Char look_for,String replace_with).String
- Replaces all instances of character 'look_for' with string 'replace_with'.
- replace(String look_for,String replace_with).String
- Replaces all instances of string 'look_for' with string 'replace_with'.
- replace(Pattern p,String replacement).String
- Replaces all occurences of pattern 'p' with the given string. The 'replacement' string may contain the insertion markers $[0], $[1], etc. These are replaced by group 0, group 1, etc. from the pattern.
- Returns the modified string.
- Example:
local Pattern name( "{id} ws {id}" )
local String regular = "Abe Pralle"
local String roster = regular.replace( name, "$[1], $[0]" )
println( roster ) # prints: Pralle, Abe
- leftmost(Int32 num_chars).String
- rightmost(Int32 num_chars).String
- excluding_leftmost(Int32 num_chars).String
- excluding_rightmost(Int32 num_chars).String
- excluding_substring(Int32 first,Int32 last).String
- before(Int32 index).String
- Returns the substring of this string that occur before the given index.
- Equivalent to leftmost(index).
- after(Int32 index).String
- Returns the substring of this string that occur after the given index.
- Equivalent to substring(index+1).
- before_first(Char ch).String
- Returns the substring of this string that occurs before the first occurrence of the given character, or returns the entire string if 'ch' does not occur in this string.
- before_last(Char ch).String
- Returns the substring of this string that occurs before the last occurrence of the given character, or returns the entire string if 'ch' does not occur in this string.
- after_last(Char ch).String
- Returns the substring of this string that occurs after the last occurrence of the given character, or returns the entire string if 'ch' does not occur in this string.
- after_first(Char ch).String
- Returns the substring of this string that occurs after the first occurrence of the given character, or returns the entire string if 'ch' does not occur in this string.
- from_first(Char ch).String
- Returns the substring of this string that occurs starting at the first occurrence of the given character, or returns an empty string if 'ch' does not occur in this string.
- before_first(String st).String
- Returns the substring of this string that occurs before the first occurrence of the given string, or returns the entire string if 'st' does not occur in this string.
- before_last(String st).String
- Returns the substring of this string that occurs before the first occurrence of the given string, or returns the entire string if 'st' does not occur in this string.
- after_last(String st).String
- Returns the substring of this string that occurs after the last occurrence of the given string, or returns the entire string if 'st' does not occur in this string.
- after_first(String st).String
- Returns the substring of this string that occurs after the last occurrence of the given string, or returns the entire string if 'st' does not occur in this string.
- from_first(String st).String
- Returns the substring of this string that occurs starting at the first occurrence of the given string, or returns an empty string if 'st' does not occur in this string.
- right_justified(Int32 min_chars[,Char fill_char]).String
- left_justified(Int32 min_chars[,Char fill_char]).String
- centered(Int32 min_chars[,Char fill_char]).String
- to_Int32([Int32 base]).Int32
- to_Int64([Int32 base]).Int64
- to_Real64().Real64
- to_File().File
- Returns a File object with this string as the filepath.
- to_uppercase().String
- to_lowercase().String
- capitalized().String
- Returns a capitalized version of this string - if the first letter is lowercase "a-z" it is turned into its uppercase equivalent. There are no other changes.
- split([Char divider_char]).String[]
- Splits this string into an array of string objects around (and not including) each character. You may wish to tidy() the string first.
- Returns: a list of String objects.
- Example:
println( "a b c ".split )
# prints: {a,b,,c,}
- trim().String
- tidy().String
- word_wrap(Int32 width).String[]
- Returns a word-wrapped version of this string as a list of lines. Existing newlines characters will cause a new line to begin immediately. Spaces immediately following existing newline characters are preserved.
- shuffled().String
- Returns a copy of this string with the characters in a random order.
- reversed().String
- Return a copy of this string with its characters in reverse order.
- to_utf8().String
- pluralize(Int32 quantity).String
- init_object()
- modification_count().Int32
- Returns a counter representing the number of times items has been added to or removed. Used by readers to detect concurrent list modification errors. For example, when an inner method removes an item from a list the modification counter is incremented. An outer "forEach" loop will detect that the count is different from its original value and throw a ConcurrentListModification error.
- first().Char
- Returns the first element of this data. This convenience method is equivalent to get(0).
- last().Char
- Returns the last element of this data. This convenience method is equivalent to get(count-1).
- end(Int32 from_end).Char
- Equivalent to get( (count-1) + from_end ).
- For example, end(0) is equivalent to last() and end(-1) is equivalent to get(count-2).
- random().Char
- Returns an element of this data at random.
- random_index().Int32
- Returns the index of a randomly selected element.
- is_empty().Logical
- Returns true if count == 0.
- is_not_empty().Logical
- Returns true if count > 0.
- index_of(Char value[,Int32 starting_index]).Int32
- Returns the first index that the given value occurs at starting at index 0 by default. (-1) is returned if 'value' is not found.
- last_index_of(Char value[,Int32 starting_index]).Int32
- Returns the last index that the given value occurs at starting at index (count-1) by default. (-1) is returned if 'value' is not found.
- contains(Char value).Logical
- Returns "true" if this data contains the given value.
- indices().Range<<Int32>>
- Returns this data's range of indices (0..count-1).
- reverse_indices().Range<<Int32>>
- to_List().Char[]
- Converts this indexed data into a list.
- to_bytes().Byte[]
- Converts this 16-byte character data into a list of 8-bit byte data. The upper 8 bits of each original Char are lost.
- create_reader().Reader<<Char>>
- Returns a reader that can be used to read() this data one element at a time.
- from(Int32 starting_index).Reader<<Char>>
- Returns a reader that can be used to read() this data one element at a time with the given 'starting_index'.
- from(Range<<Int32>> range).Reader<<Char>>
- Returns a reader that can be used to read() this data one element at a time from the given starting index up to and including the ending index.
- reverse_order().Reader<<Char>>
- Returns a reader that can be used to read() this data one element at a time from the last element (N-1) to the first (0).
- format(String prefix,String prepeat,String suffix).String
- Converts this list into a string using the following format:
-
prefix + $0 + [prepeat + $N]* + suffix
where "$0" is the first element and $N is every other element.
- Example:
-
local Int32[] nums = 11..15
println( nums.to_String("[", "+", "]") )
# prints: [11+12+13+14+15]
- format(String str_format[,String repeater_chars]).String
- Easier convenience method to accomplish to_String(prefix,prepeat,suffix).
- Breaks down a simple format like this:
-
{$[ or $]}
Into a prefix="{", prepeat=" or ", suffix="}".
- Normally "[]" brackets are used to denote the repeater portion, but this may be specified otherwise.
- Example:
-
local Int32[] nums = 11..15
println( nums.to_String( "[$:+$:]", ":" )
# prints: [11+12+13+14+15]
println( nums.to_String( "{$[,$]}" )
# prints: {11,12,13,14,15}
- substring(Int32 i1,Int32 i2).String
- type_name().String : native
- runtime_type().RuntimeType : native
- runtime_properties().RuntimeProperties
- runtime_methods().RuntimeMethods
|