Skip to content

Snooful/Smart-Splitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"]