Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Split a string after each substring matching a string pattern
ResourceFunction["StringSplitAfter"]["string"] splits "string" into a list of substrings after each whitespace. | |
ResourceFunction["StringSplitAfter"]["string",patt] splits "string" into substrings after delimiters matching the string expression patt. | |
ResourceFunction["StringSplitAfter"]["string",{p1,p2,…}] splits "string" after any of the pi. | |
ResourceFunction["StringSplitAfter"]["string",patt→val] replaces each delimiter matching patt with val. | |
ResourceFunction["StringSplitAfter"]["string",{p1→v1,…}] replaces each delimiter matching pi with vi. | |
ResourceFunction["StringSplitAfter"][{s1,s2,…},p] gives the list of results for each of the si. |
Split a string after each whitespace (without removing the whitespace):
In[1]:= |
Out[1]= |
Split a string after every "--" (without removing the "--"):
In[2]:= |
Out[2]= |
Split after every run of spaces:
In[3]:= |
Out[3]= |
Use string patterns:
In[4]:= |
Out[4]= |
In[5]:= |
Out[5]= |
In[6]:= |
Out[6]= |
Regular expressions:
In[7]:= |
Out[7]= |
Mixed regular expressions and string patterns:
In[8]:= |
Out[8]= |
Split into substrings after either delimiter:
In[9]:= |
Out[9]= |
In[10]:= |
Out[10]= |
Replace a delimiter:
In[11]:= |
Out[11]= |
SplitStringAfter automatically threads over lists of strings:
In[12]:= |
Out[12]= |
Split a string after every "c", including uppercase letters:
In[13]:= |
Out[13]= |
This work is licensed under a Creative Commons Attribution 4.0 International License