v1.2.0.1-beta1
|
Extends String object.
Public Member Functions | |
string | arg (value) |
string | format (format, args) |
string | simplified () |
string | appendLine (String line, int maxLines, separator='\n') |
string | getLines (int maxLines, int fromLine=0, String separator='\n') |
Static Public Member Functions | |
string | appendLine (String text, String line, int maxLines, String separator='\n') |
string | getLines (String text, int maxLines, int fromLine=0, String separator='\n') |
string arg | ( | value | ) |
Returns a copy of this string with the lowest numbered place marker replaced by value.
Place markers begin with a %
symbol followed by a number in the 1 through 99 range, i.e. %1, %2, ..., %99.
The following example prints "There are 20 items":
String.format()
, sprintf()
string format | ( | format, | |
args | |||
) |
Formats format
string using the provided arguments in args
, if any, using .NET-style formatting syntax.
format | The formatting string used to format the additional arguments. |
args | Zero or more arguments for the format string. |
Formatting is done using format strings almost completely compatible with the String.Format method in Microsoft .NET Framework.
For example:
There is also a convenience global function available as an alias, named simply Format()
. It works identically to String.format()
but is shorter to type.
See formatting string reference at
https://learn.microsoft.com/en-us/dotnet/standard/base-types/formatting-types
This extension is originally from the String.format for JavaScript project. There are some examples and references available at that site. The original sffjs
object referenced in their documentation is available in this script engine as Sffjs
.
Number.format()
, Date.format()
, and sprintf()
for "printf-style" string formatting. string simplified | ( | ) |
Returns this string with leading, trailing, and all redundant internal whitespace removed.
contents of this byte array as a Base64-encoded string. Example:
string appendLine | ( | String | line, |
int | maxLines, | ||
separator = '\n' |
|||
) |
Appends string line
to current string, and returns a new block with up to maxLines
lines.
If maxLines
is zero or negative, returns the full resulting string. The newline (\n
) is used as separator by default, or a custom separator string can be specified in separator
argument.
Appends string line
to text
and returns a new block with up to maxLines
lines.
Static version of String.prototype.appendLine()
, above. Used, for example, like this: String.appendLine("Original string", "New line to append", 4)
string getLines | ( | int | maxLines, |
int | fromLine = 0 , |
||
String | separator = '\n' |
||
) |
Splits string text
into lines based on separator
and returns maxLines
of text starting at fromLine
(zero-based index).
Default maxLines
is 1, fromLine
is zero (the start) and default separator
is "\n". Specify a negative fromLine
to count lines from the end instead of the beginning (so -1
returns one line from the end). The result may be the complete input if there were fewer then maxLines
found in it.
Splits string text
into lines based on separator
and returns maxLines
of text starting at fromLine
(zero-based index).
Static version of String.prototype.getLines()
, above. Used, for example, like this: String.getLines("Text\nWith some\nLines\n", 1, -1)