StringTools - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Names and Strings : StringTools Package : String Homology Routines : StringTools/CommonPrefix

StringTools

  

CommonPrefix

  

return the length of the longest common prefix of two strings

  

CommonSuffix

  

return the length of the longest common suffix of two strings

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

CommonPrefix( s1, s2 )

CommonSuffix( s1, s2 )

Parameters

s1

-

Maple string

s2

-

Maple string

Description

• 

The CommonPrefix(s1, s2) command returns the length of the longest common prefix of its input strings, s1 and s2.

  

The actual common prefix can be obtained by indexing into either of the strings, s1 or s2, with the range 1 .. CommonPrefix( s1, s2 ).

  

Note: String t is a prefix of string s if t=s1..n, for some integer 1nlengths, or t is the empty string. For example, the prefixes of the string "abc" are "", "a", "ab", and "abc".

• 

The CommonSuffix(s1, s2) function returns the length of the longest common suffix of its input strings, s1 and s2.

  

This function can be defined, in terms of CommonPrefix and Reverse as

CommonSuffixs1,s2=CommonPrefixReverses1,Reverses2

Examples

withStringTools:

CommonPrefixabc,ab

2

(1)

CommonPrefixabc,xab

0

(2)

CommonPrefix,ab

0

(3)

sabc:

tab:

s1..CommonPrefixs,t

ab

(4)

t1..CommonPrefixs,t

ab

(5)

CommonSuffixabc,xbc

2

(6)

CommonSuffixabc,xbcd

0

(7)

See Also

string

StringTools

StringTools[IsPrefix]

StringTools[IsSuffix]

StringTools[Reverse]

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam