Deutsche Version
Version History
Version |
Modification |
1.0 (2024-06-15) |
Initial version |
Download
The ZIP archive UrsAI2StringUtils
for downloading. The archive contains the source code and the compiled binary and a sample project
to upload to the App Inventor.
Usage
This extension offers a number of auxiliary functions for editing texts. These are taken from the
Apache String Utils (source
code on GitHub).
Many functions exist in two or three variants:
- Functions without a special ending refer to the string defined with the
Text property, but do not change it.
Example:
RemoveFirstChar returns a new string, starting with the second character of
the string defined with the Text property. The
Text property is not changed.
- Functions with the suffix ...This change the string defined with the
Text property.
Example:
RemoveFirstCharThis deletes the first character from the string defined
with the Text property. The
Text property now has a new value.
- Functions with the ending ...Of refer to a text passed to the function.
Example: RemoveFirstCharOf returns a new character
string starting with the second character of the text passed.
Reference
Properties
- Text
- Defines the text to be edited or retrieves it.
- Version
- Returns the version of this extension.
- VersionSDK ()
- Returns running Android SDK version.
Methods
- Abbreviate (Marker, MaxWidth)
- Get an abbreviation of the set text using a given replacement marker. This will turn "Now is the time for all
good men." into "Now is the time for..." if "..." was defined as the replacement marker.
- AbbreviateOf (Text, Marker,
MaxWidth)
- Abbreviates a text using a given replacement marker. This will turn "Now is the time for all good men." into
"Now is the time for..." if "..." was defined as the replacement marker.
- AbbreviateThis (Marker, MaxWidth)
- Abbreviates the set text using a given replacement marker. This will turn "Now is the time for all good men."
into "Now is the time for..." if "..." was defined as the replacement marker.
- Center (Size, PadChar)
- Gets the set text centered in a larger text of size Size.
- CenterOf (Text, Size,
PadChar)
- Centers a text in a larger text of size Size.
- CenterThis (Size, PadChar)
- Centers the set text in a larger text of size Size.
- CharAt (Index)
- Gets the character at position Index (1 based) of the set text. Returns ""
if Index > length of the set text.
- CharAtOf (Text, Index)
- Gets the character at position Index (1 based) of a text. Returns "" if
Index > length of the text.
- EndsWith (Suffix, IgnoreCase)
- Checks if the set text ends with a specified suffix (optionally case insensitive).
- EndsWithOf (Text, Suffix,
IgnoreCase)
- Checks if a text ends with a specified suffix (optionally case insensitive).
- IsDigit (CharAt)
- Returns true if the character at position CharAt (1 based) of the set text
is a digit (see
Character.isDigit).
Returns false if CharAt > length of the set
text.
- IsDigitOf (Text, CharAt)
- Returns true if the character at position CharAt (1 based) of
Text is a digit (see
Character.isDigit).
Returns false if CharAt > length of the
Text.
- IsEmpty (CharAt)
- Checks if the set text is empty ("").
- IsEmptyOf (Text, CharAt)
- Checks if Text is empty ("").
- IsLetter (CharAt)
- Returns true if the character at position CharAt (1 based) of the set text
is a letter (see
Character.isLetter).
Returns false if CharAt > length of the set
text.
- IsLetterOf (Text, CharAt)
- Returns true if the character at position CharAt (1 based) of
Text is a letter (see
Character.isLetter).
Returns false if CharAt > length of
Text.
- IsLetterOrDigit (CharAt)
- Returns true if the character at position CharAt (1 based) of the set text
is a letter or a digit (see
Character.isLetter,
Character.isDigit). Returns false if
CharAt > length of the set text.
- IsLetterOrDigitOf (Text,
CharAt)
- Returns true if the character at position CharAt (1 based) of
Text is a letter or a digit (see
Character.isLetter,
Character.isDigit).
Returns false if CharAt > length of
Text.
- IsWhiteSpace (CharAt)
- Returns true if the character at position CharAt (1 based) of the set text
is whitespace (see
Character.isWhiteSpace). Returns false if
CharAt > length of the set text.
- IsWhiteSpaceOf (Text, CharAt)
- Returns true if the character at position CharAt (1 based) of
Text is a whitespace (see
Character.isWhiteSpace). Returns false if
CharAt > length of Text.
- Left (Count)
- Gets the leftmost Count characters of the set text.
- LeftOf (Text, Count)
- Gets the leftmost Count characters of Text.
- LeftThis (Count)
- Sets the stored text to the leftmost Count characters of the set text.
- LeftPad (Size, PadChar)
- Gets the set text left padded with the specified character. Size is the final
size of the text.
- LeftPadOf (Text, Size,
PadChar)
- Left pad a text with a specified character. Size is the final size of the
text.
- LeftPadThis (Size, PadChar)
- Left pad the set text with a specified character. Size is the final size of
the text.
- LevenshteinDistance (Left,
Right)
- Find the Levenshtein distance
between two Strings. A higher score indicates a greater distance.
- Mid (Start, Count)
- Gets Count characters from the middle of the set text.
- MidOf (Text, Start,
Count)
- Gets Count characters from the middle of Text.
- MidThis (Start, Count)
- Sets the stored text to Count characters from the middle of the set text.
- RemoveFirstChar ()
- Gets the set text without the first character.
- RemoveFirstCharOf (Text)
- Removes the first character from Text.
- RemoveFirstCharOfThis ()
- Removes the first character from the set text.
- RemoveLastChar ()
- Gets the set text without the last character.
- RemoveLastCharOf (Text)
- Removes the last character from Text.
- RemoveLastCharOfThis ()
- Removes the last character from the set text.
- Repeat (Text, Count)
- Repeat Text Count times to form a new text.
- Right (Count)
- Gets the rightmost Count characters of the set text.
- RightOf (Text, Count)
- Gets the rightmost Count characters of Text.
- RightThis (Count)
- Sets the stored text to the rightmost Count characters of the set text.
- RightPad (Size, PadChar)
- Gets the set text right padded with the specified character. Size is the final
size of the text.
- RightPadOf (Text, Size,
PadChar)
- Fills Text on the right with the specified character. Size is the final size
of the text.
- RightPadThis (Size, PadChar)
- Fills the stored text on the right with the specified character. Size is the
final size of the text.
- StartsWith (Prefix, IgnoreCase)
- Checks if the set text starts with the specified Prefix (optionally case insensitive).
- StartsWithOf (Text, Prefix,
IgnoreCase)
- Checks if Text starts with the specified Prefix
(optionally case insensitive).
- SwapCase ()
- Gets a case swapped version of the set text changing upper and title case to lower case, and lower case to upper
case.
- SwapCaseOf (Text)
- Swaps the case of Text changing upper case to lower case, and lower case to
upper case.
- SwapCaseThis ()
- Swaps the case of the set text changing upper and title case to lower case, and lower case to upper case.
Events
- None
Example
The example applies many of the defined functions to an entered text:
For developing own extensions I gathered some tips:
AI2 FAQ: Develop Extensions.