# String.split on a sub-string within a pattern?

**URL:** <https://forum.elixirforum.com/t/string-split-on-a-sub-string-within-a-pattern/2133>\
**Category:** Questions\
**Tags:** regexp, exercism\
**Created:** [October 26, 2016, 12:31pm UTC](https://forum.elixirforum.com/t/string-split-on-a-sub-string-within-a-pattern/2133 "2016-10-26T12:31:36Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![MatthewMDavis](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/matthewmdavis/32/2783_2.png) [@MatthewMDavis](https://forum.elixirforum.com/u/MatthewMDavis)\
**Post date:** [October 26, 2016, 2:55pm UTC](https://forum.elixirforum.com/t/string-split-on-a-sub-string-within-a-pattern/2133/7 "2016-10-26T14:55:33Z")

</div>

No, that won’t work. If I split on ALL non-word characters, my mathematical operators vanish. I need to be able to keep the operators (characters in the class [±\*/], and surrounded by whitespace).

I may end up pre-processing the string and converting the operators to words for the operations they represent. Then if I just split on non-word characters, everything is easy. But I also have to re-convert them back to the original characters at the end. So this seemed like a potentially better way.

---

_[View the full topic](https://forum.elixirforum.com/t/string-split-on-a-sub-string-within-a-pattern/2133)._
