The source string to extract a substring from
A trimmed substring of the original content
const text = "The quick brown fox jumps over the lazy dog";
RandomGenerator.substring(text); // e.g. "quick brown fox"
RandomGenerator.substring(text); // e.g. "jumps over"
RandomGenerator.substring(text); // e.g. "fox jumps over the lazy"
// Generate search terms from content
const searchQuery = RandomGenerator.substring(articleContent);
// Create excerpts for previews
const excerpt = RandomGenerator.substring(fullBlogPost);
// Generate partial matches for testing search functionality
const partialMatch = RandomGenerator.substring(productDescription);
// Create random selections for highlight testing
const selectedText = RandomGenerator.substring(documentContent);
contracts/common.md#principled-implementation For nonempty input, the first index is a valid position and the last is strictly later up to the length. Trimming can empty a whitespace slice. Empty input also returns an empty string; substring clamps its drawn bounds to the empty input.
Extracts a random substring from the provided content string.
Selects two random positions within the content and returns the substring between them. The starting position is always before the ending position. Automatically trims whitespace from the beginning and end of the result. Useful for creating excerpts, search terms, or partial content samples.
Processing cost: Two draws choose the slice bounds; substring and trimming cost at most O(N) in the input length.