Function Repository Resource:

StringUnion

Source Notebook

Find the distinct characters in multiple strings

Contributed by: Arnoud Buzing

ResourceFunction["StringUnion"][s1,s2,]

gives a string containing all the distinct characters in any of the si.

Details and Options

Characters in the returned string are sorted in standard order.

Examples

Basic Examples (1) 

Find characters contained in a couple of strings:

In[1]:=
ResourceFunction["StringUnion"]["Hello", "World"]
Out[1]=

Scope (2) 

Use any number of strings:

In[2]:=
ResourceFunction[
 "StringUnion"]["Which of the characters are distinct?", "Some of these", "And some of these", "Don't forget these"]
Out[2]=

All characters are supported:

In[3]:=
{str1, str2} = TextCases[ResourceData["The Odyssey - Greek"], "Sentence"][[1 ;; 2]]
Out[3]=
In[4]:=
ResourceFunction["StringUnion"][str1, str2]
Out[4]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 11 October 2018

License Information