Function Repository Resource:

StringOverlaps

Source Notebook

Find substrings that overlap between strings

Contributed by: Stephen Wolfram

ResourceFunction["StringOverlaps"][{string1,string2,}]

gives a list of overlaps that exist between any of the stringi.

ResourceFunction["StringOverlaps"][string]

gives overlaps of string with itself.

Examples

Basic Examples (2) 

These two strings cannot overlap:

In[1]:=
ResourceFunction["StringOverlaps"][{"AAA", "BBB"}]
Out[1]=

These two strings can only overlap in one way:

In[2]:=
ResourceFunction["StringOverlaps"][{"AAB", "BCC"}]
Out[2]=

These strings can overlap in either order:

In[3]:=
ResourceFunction["StringOverlaps"][{"BAB", "BCCB"}]
Out[3]=

These strings can overlap in several ways:

In[4]:=
ResourceFunction["StringOverlaps"][{"AABBB", "BBBCC"}]
Out[4]=

This string cannot overlap with itself:

In[5]:=
ResourceFunction["StringOverlaps"]["AABB"]
Out[5]=

This string can overlap with itself in multiple ways:

In[6]:=
ResourceFunction["StringOverlaps"]["AAAAA"]
Out[6]=

Properties and Relations (1) 

Constant strings have overlaps that vary in length:

In[7]:=
ResourceFunction["StringOverlaps"]["AAAAA"]
Out[7]=
In[8]:=
ResourceFunction["StringOverlaps"][{"AAAAA", "AAAAA"}]
Out[8]=

Version History

  • 1.0.0 – 04 December 2019

Related Resources

License Information