# String Manipulation: How do you split a string of data?

**URL:** <https://community.wolfram.com/t/string-manipulation-how-do-you-split-a-string-of-data/4620>\
**Category:** Questions\
**Tags:** biological-sciences, data-science, mathematica\
**Created:** [January 24, 2015, 9:19pm UTC](https://community.wolfram.com/t/string-manipulation-how-do-you-split-a-string-of-data/4620 "2015-01-24T21:19:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marksepulveda1](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@marksepulveda1](https://community.wolfram.com/u/marksepulveda1)\
**Post date:** [January 24, 2015, 9:19pm UTC](https://community.wolfram.com/t/string-manipulation-how-do-you-split-a-string-of-data/4620/1 "2015-01-24T21:19:05Z")

</div>

I am fairly new to mathematica. I am trying to split a string and output it as triplets.  
I have tried playing with the StringSplit, Split, and Partition functions to no avail.

Here is a sample:

[IN] “955929400769971”  
[OUT] 955 929 400 769 971

Any ideas would be appreciated.

---

<div class="post-metadata">

**Author:** ![nma](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@nma](https://community.wolfram.com/u/nma)\
**Post date:** [January 24, 2015, 10:08pm UTC](https://community.wolfram.com/t/string-manipulation-how-do-you-split-a-string-of-data/4620/2 "2015-01-24T22:08:25Z")

</div>

one way might be

```
str = "955929400769971";
c = Partition[Characters[str], 3];
c = Insert[#, " ", -1] & /@ c;
StringJoin[StringJoin[#] & /@ c]

```

Which gives

```
"955 929 400 769 971 "

```

And if you just want the strings in a list:

```
str = "955929400769971";
c = Partition[Characters[str], 3];
StringJoin[#] & /@ c

```

gives

```
{"955", "929", "400", "769", "971"}

```

---

<div class="post-metadata">

**Author:** ![marksepulveda1](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@marksepulveda1](https://community.wolfram.com/u/marksepulveda1)\
**Post date:** [January 24, 2015, 10:26pm UTC](https://community.wolfram.com/t/string-manipulation-how-do-you-split-a-string-of-data/4620/3 "2015-01-24T22:26:19Z")

</div>

Thank you Nasser. That worked like a champ. Now to the docs to analyze what you did ;). I appreciate the assistance.

---

<div class="post-metadata">

**Author:** ![kubapod](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/kubapod/32/18662_2.png) [@kubapod](https://community.wolfram.com/u/kubapod)\
**Post date:** [January 25, 2015, 12:00am UTC](https://community.wolfram.com/t/string-manipulation-how-do-you-split-a-string-of-data/4620/4 "2015-01-25T00:00:22Z")

</div>

Just for fun:

```
StringCases[
 "955929400769971",
 Repeated[_, {3}]
 ]

```

> {“955”, “929”, “400”, “769”, “971”}

---

<div class="post-metadata">

**Author:** ![gdelfino](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/gdelfino/32/41294_2.png) [@gdelfino](https://community.wolfram.com/u/gdelfino)\
**Post date:** [January 25, 2015, 5:01pm UTC](https://community.wolfram.com/t/string-manipulation-how-do-you-split-a-string-of-data/4620/5 "2015-01-25T17:01:51Z")

</div>

This is similar to Nasser’s answer, but using Riffle instead of Insert:

```
In[1]:= StringJoin@Riffle[Partition[Characters@"955929400769971",3]," "]
Out[1]= 955 929 400 769 971

```
