MaximalPalindromicSubstring - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

# Online Help

###### All Products    Maple    MapleSim

StringTools

 MaximalPalindromicSubstring
 find a maximal palindromic substring of a string

 Calling Sequence MaximalPalindromicSubstring( s )

Parameters

 s - string; any Maple string

Description

 • The MaximalPalindromicSubstring command  computes a maximal palindromic substring of the string s. A string $t$ is a palindrome if it is equal to itself reversed, that is, $t=\mathrm{Reverse}\left(t\right)$.
 • If s is nonempty and contains no substrings that are palindromes, the first character of s is the maximal palindromic substring. If s is empty, the empty string ("") is the maximal palindromic substring.
 • The maximal palindromic substring of s is indicated by returning a sequence of two non-negative integers:
 • The first is the index of the beginning of the palindromic substring in the string s.
 • The second is the length of the palindromic substring.
 • All of the StringTools package commands treat strings as (null-terminated) sequences of $8$-bit (ASCII) characters.  Thus, there is no support for multibyte character encodings, such as unicode encodings.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{MaximalPalindromicSubstring}\left(""\right)$
 ${0}{,}{0}$ (1)
 > $\mathrm{MaximalPalindromicSubstring}\left("abcde"\right)$
 ${1}{,}{1}$ (2)
 > $\mathrm{pos},\mathrm{len}≔\mathrm{MaximalPalindromicSubstring}\left("abcbde"\right)$
 ${\mathrm{pos}}{,}{\mathrm{len}}{≔}{2}{,}{3}$ (3)
 > ${"abcbde"}_{\mathrm{pos}..\mathrm{pos}+\mathrm{len}-1}$
 ${"bcb"}$ (4)

 See Also