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.
Example
consttext = "The quick brown fox jumps over the lazy dog";
RandomGenerator.substring(text); // "quick brown fox" RandomGenerator.substring(text); // "jumps over" RandomGenerator.substring(text); // "fox jumps over the lazy"
// Generate search terms from content constsearchQuery = RandomGenerator.substring(articleContent);
// Create excerpts for previews constexcerpt = RandomGenerator.substring(fullBlogPost);
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.
Example