smart-splitter

Split strings the smarter way.

Usage no npm install needed!

<script type="module">
  import smartSplitter from 'https://cdn.skypack.dev/smart-splitter';
</script>

README

Smart Splitter

GitHub release npm Travis (.com)

Split strings the smarter way.

Why?

A developer might parse arguments using String#split, but this falls apart as soon as multi-word arguments need to be parsed:

"--force -m hey!".split(" "); // It works...
"--force -m 'hello world'".split(" "); // Nope: [..., "'hello", "world'"]

Smart Splitter aims to solve this problem. Quoted text remains as one string and does not contain quotes:

smartSplit("--force -m 'hello world'"); // Nice: ["--force", "-m", "hello world"]