fragment_of_characters

Use the fragment_of_characters function to extract a fragment from a larger text.

The function is capable of handling Unicode characters and word processor instructions.

fragment_of_characters ( input; offset; length )

This function returns a value of type TEXT.

The function has three parameters:

  1. input, type TEXT. The text from which the fragment is taken.
  2. offset, type NUMBER. The position of the first character of the fragment.
  3. length, type NUMBER. The number of characters in the fragment.

offset starts at 1 for the first character in input. A negative or 0 value is interpreted as the beginning of the value.

A negative or 0 value for length results in an empty result. If the requested fragment exceeds the number of available characters in input, the result only contains the available characters from input.

The input is always converted to Unicode Normalization Form C (NFC). This can cause merge or reordering of characters in the text.

Tabs, paragraph breaks, and line breaks are handled as characters. Other word processor content, such as layout switches and graphical object, is stripped. The stripped content is not counted when calculating the offset and length and not included in the resulting fragment.

The resulting output is also in Unicode Normalization Form C (NFC).

Examples

Examples:
fragment_of_characters (“abcdefgh”;  2;  4) 	results in “bcde”
fragment_of_characters (“abcdefgh”; 20;  4)	results in “”
fragment_of_characters (“abcdefgh”; -2;  4)	results in “abcd”
fragment_of_characters (“abcdefgh”;  2; -4)	results in “”
fragment_of_characters (“abcdefgh”;  2; 20)	results in “bcdefgh”

The fragment_of_characters function supercedes the text_fragment function.