CommonSuffix

STD.Str.CommonSuffix( s1, s2 [ ,nocase ] )

STD.Uni.CommonSuffix( s1, s2 [ ,nocase ] )

s1A string to compare.
s2A string to compare.
nocaseOptional. If TRUE, the comparison is case-insensitive. If omitted, the default is FALSE.
Return:CommonSuffix returns either a STRING or UNICODE value, as appropriate. It contains the longest suffix common to both strings, as copied from the first argument. The result is empty if the strings have no common suffix or if either argument is empty.

The CommonSuffix function returns the longest suffix common to both strings. This can be useful for identifying shared endings between strings, which can be helpful in text processing tasks such as pattern matching, data normalization, or linguistic analysis.

Example:

IMPORT Std;
Std.Str.CommonSuffix('SUNLIGHT', 'MOONLIGHT',nocase:=FALSE); // NLIGHT
Std.Str.CommonSuffix('TABLETOP', 'Laptop',FALSE);            // empty
Std.Str.CommonSuffix('TABLETOP', 'Laptop',TRUE);             // TOP
Std.Str.CommonSuffix('APPLES', 'ORANGES',FALSE);             // ES 

See Also: CommonPrefix