This class provides advanced methods on Strings. It is ideally used with using StringTools and then acts as an extension to the String class.

If the first argument to any of the methods is null, the result is unspecified.

Static methods

staticinlinecontains(s:String, value:String):Bool

Returns true if s contains value and false otherwise.

When value is null, the result is unspecified.

@:has_untypedstaticendsWith(s:String, end:String):Bool

Tells if the string s ends with the string end.

If end is null, the result is unspecified.

If end is the empty String "", the result is true.

staticfastCodeAt(s:String, index:Int):Int

Returns the character code at position index of String s, or an end-of-file indicator at if position equals s.length.

This method is faster than String.charCodeAt() on some platforms, but the result is unspecified if index is negative or greater than s.length.

End of file status can be checked by calling StringTools.isEof() with the returned value as argument.

This operation is not guaranteed to work if s contains the \0 character.

statichex(n:Int, ?digits:Int):String

Encodes n into a hexadecimal representation.

If digits is specified, the resulting String is padded with "0" until its length equals digits.

statichtmlEscape(s:String, ?quotes:Bool):String

Escapes HTML special characters of the string s.

The following replacements are made:

  • & becomes &
  • < becomes &lt;
  • > becomes &gt;

If quotes is true, the following characters are also replaced:

  • " becomes &quot;
  • ' becomes &#039;

statichtmlUnescape(s:String):String

Unescapes HTML special characters of the string s.

This is the inverse operation to htmlEscape, i.e. the following always holds: htmlUnescape(htmlEscape(s)) == s

The replacements follow:

  • &amp; becomes &
  • &lt; becomes <
  • &gt; becomes >
  • &quot; becomes "
  • &#039; becomes '

@:noUsingstaticinlineisEof(c:Int):Bool

Tells if c represents the end-of-file (EOF) character.

staticisSpace(s:String, pos:Int):Bool

Tells if the character in the string s at position pos is a space.

A character is considered to be a space character if its character code is 9,10,11,12,13 or 32.

If s is the empty String "", or if pos is not a valid position within s, the result is false.

staticinlineiterator(s:String):StringIterator

Returns an iterator of the char codes.

Note that char codes may differ across platforms because of different internal encoding of strings in different runtimes. For the consistent cross-platform UTF8 char codes see haxe.iterators.StringIteratorUnicode.

staticinlinekeyValueIterator(s:String):StringKeyValueIterator

Returns an iterator of the char indexes and codes.

Note that char codes may differ across platforms because of different internal encoding of strings in different of runtimes. For the consistent cross-platform UTF8 char codes see haxe.iterators.StringKeyValueIteratorUnicode.

staticlpad(s:String, c:String, l:Int):String

Concatenates c to s until s.length is at least l.

If c is the empty String "" or if l does not exceed s.length, s is returned unchanged.

If c.length is 1, the resulting String length is exactly l.

Otherwise the length may exceed l.

If c is null, the result is unspecified.

@:has_untypedstaticltrim(s:String):String

Removes leading space characters of s.

This function internally calls isSpace() to decide which characters to remove.

If s is the empty String "" or consists only of space characters, the result is the empty String "".

@:has_untypedstaticreplace(s:String, sub:String, by:String):String

Replace all occurrences of the String sub in the String s by the String by.

If sub is the empty String "", by is inserted after each character of s except the last one. If by is also the empty String "", s remains unchanged.

If sub or by are null, the result is unspecified.

staticrpad(s:String, c:String, l:Int):String

Appends c to s until s.length is at least l.

If c is the empty String "" or if l does not exceed s.length, s is returned unchanged.

If c.length is 1, the resulting String length is exactly l.

Otherwise the length may exceed l.

If c is null, the result is unspecified.

@:has_untypedstaticrtrim(s:String):String

Removes trailing space characters of s.

This function internally calls isSpace() to decide which characters to remove.

If s is the empty String "" or consists only of space characters, the result is the empty String "".

@:has_untypedstaticstartsWith(s:String, start:String):Bool

Tells if the string s starts with the string start.

If start is null, the result is unspecified.

If start is the empty String "", the result is true.

@:has_untypedstatictrim(s:String):String

Removes leading and trailing space characters of s.

This is a convenience function for ltrim(rtrim(s)).

@:has_untypedstaticurlDecode(s:String):String

Decode an URL using the standard format.

@:has_untypedstaticurlEncode(s:String):String

Encode an URL by using the standard format.