{\bfseries{Why use this?}}

\begin{quote}
Split a string on a character except when the character is escaped. \end{quote}
Please consider following this project\textquotesingle{}s author, \href{https://github.com/jonschlinkert}{\texttt{ Jon Schlinkert}}, and consider starring the project to show your \+:heart\+: and support.\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28662}{}\doxysection{Install}\label{md_sfcode_node_modules_split_string_README_autotoc_md28662}
Install with \href{https://www.npmjs.com/}{\texttt{ npm}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install -\/-\/save split-\/string }

\end{DoxyCode}


$<$details$>$

~\newline


Although it\textquotesingle{}s easy to split on a string\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{console.log('a.b.c'.split('.'));}
\DoxyCodeLine{//=> ['a', 'b', 'c'] }

\end{DoxyCode}


It\textquotesingle{}s more challenging to split a string whilst respecting escaped or quoted characters.

{\bfseries{Bad}}


\begin{DoxyCode}{0}
\DoxyCodeLine{console.log('a\(\backslash\)\(\backslash\).b.c'.split('.'));}
\DoxyCodeLine{//=> ['a\(\backslash\)\(\backslash\)', 'b', 'c']}
\DoxyCodeLine{}
\DoxyCodeLine{console.log('"{}a.b.c"{}.d'.split('.'));}
\DoxyCodeLine{//=> ['"{}a', 'b', 'c"{}', 'd'] }

\end{DoxyCode}


{\bfseries{Good}}


\begin{DoxyCode}{0}
\DoxyCodeLine{var split = require('split-\/string');}
\DoxyCodeLine{console.log(split('a\(\backslash\)\(\backslash\).b.c'));}
\DoxyCodeLine{//=> ['a.b', 'c']}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(split('"{}a.b.c"{}.d'));}
\DoxyCodeLine{//=> ['a.b.c', 'd'] }

\end{DoxyCode}


See the \href{\#options}{\texttt{ options}} to learn how to choose the separator or retain quotes or escaping.

~\newline


$<$/details$>$\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28663}{}\doxysection{Usage}\label{md_sfcode_node_modules_split_string_README_autotoc_md28663}

\begin{DoxyCode}{0}
\DoxyCodeLine{var split = require('split-\/string');}
\DoxyCodeLine{}
\DoxyCodeLine{split('a.b.c');}
\DoxyCodeLine{//=> ['a', 'b', 'c']}
\DoxyCodeLine{}
\DoxyCodeLine{// respects escaped characters}
\DoxyCodeLine{split('a.b.c\(\backslash\)\(\backslash\).d');}
\DoxyCodeLine{//=> ['a', 'b', 'c.d']}
\DoxyCodeLine{}
\DoxyCodeLine{// respects double-\/quoted strings}
\DoxyCodeLine{split('a."{}b.c.d"{}.e');}
\DoxyCodeLine{//=> ['a', 'b.c.d', 'e'] }

\end{DoxyCode}


{\bfseries{Brackets}}

Also respects brackets \href{\#optionsbrackets}{\texttt{ unless disabled}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{split('a (b c d) e', ' ');}
\DoxyCodeLine{//=> ['a', '(b c d)', 'e'] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28664}{}\doxysection{Options}\label{md_sfcode_node_modules_split_string_README_autotoc_md28664}
\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28665}{}\doxysubsection{options.\+brackets}\label{md_sfcode_node_modules_split_string_README_autotoc_md28665}
{\bfseries{Type}}\+: {\ttfamily object$\vert$boolean}

{\bfseries{Default}}\+: {\ttfamily undefined}

{\bfseries{Description}}

If enabled, split-\/string will not split inside brackets. The following brackets types are supported when {\ttfamily options.\+brackets} is {\ttfamily true},


\begin{DoxyCode}{0}
\DoxyCodeLine{\{}
\DoxyCodeLine{  '<': '>',}
\DoxyCodeLine{  '(': ')',}
\DoxyCodeLine{  '[': ']',}
\DoxyCodeLine{  '\{': '\}'}
\DoxyCodeLine{\} }

\end{DoxyCode}


Or, if object of brackets must be passed, each property on the object must be a bracket type, where the property key is the opening delimiter and property value is the closing delimiter.

{\bfseries{Examples}}


\begin{DoxyCode}{0}
\DoxyCodeLine{// no bracket support by default}
\DoxyCodeLine{split('a.\{b.c\}');}
\DoxyCodeLine{//=> [ 'a', '\{b', 'c\}' ]}
\DoxyCodeLine{}
\DoxyCodeLine{// support all basic bracket types: "{}<>\{\}[]()"{}}
\DoxyCodeLine{split('a.\{b.c\}', \{brackets: true\});}
\DoxyCodeLine{//=> [ 'a', '\{b.c\}' ]}
\DoxyCodeLine{}
\DoxyCodeLine{// also supports nested brackets }
\DoxyCodeLine{split('a.\{b.\{c.d\}.e\}.f', \{brackets: true\});}
\DoxyCodeLine{//=> [ 'a', '\{b.\{c.d\}.e\}', 'f' ]}
\DoxyCodeLine{}
\DoxyCodeLine{// support only the specified brackets}
\DoxyCodeLine{split('[a.b].(c.d)', \{brackets: \{'[': ']'\}\});}
\DoxyCodeLine{//=> [ '[a.b]', '(c', 'd)' ] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28666}{}\doxysubsection{options.\+sep}\label{md_sfcode_node_modules_split_string_README_autotoc_md28666}
{\bfseries{Type}}\+: {\ttfamily string}

{\bfseries{Default}}\+: {\ttfamily .}

The separator/character to split on.

{\bfseries{Example}}


\begin{DoxyCode}{0}
\DoxyCodeLine{split('a.b,c', \{sep: ','\});}
\DoxyCodeLine{//=> ['a.b', 'c']}
\DoxyCodeLine{}
\DoxyCodeLine{// you can also pass the separator as string as the last argument}
\DoxyCodeLine{split('a.b,c', ',');}
\DoxyCodeLine{//=> ['a.b', 'c'] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28667}{}\doxysubsection{options.\+keep\+Escaping}\label{md_sfcode_node_modules_split_string_README_autotoc_md28667}
{\bfseries{Type}}\+: {\ttfamily boolean}

{\bfseries{Default}}\+: {\ttfamily undefined}

Keep backslashes in the result.

{\bfseries{Example}}


\begin{DoxyCode}{0}
\DoxyCodeLine{split('a.b\(\backslash\)\(\backslash\).c');}
\DoxyCodeLine{//=> ['a', 'b.c']}
\DoxyCodeLine{}
\DoxyCodeLine{split('a.b.\(\backslash\)\(\backslash\)c', \{keepEscaping: true\});}
\DoxyCodeLine{//=> ['a', 'b\(\backslash\).c'] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28668}{}\doxysubsection{options.\+keep\+Quotes}\label{md_sfcode_node_modules_split_string_README_autotoc_md28668}
{\bfseries{Type}}\+: {\ttfamily boolean}

{\bfseries{Default}}\+: {\ttfamily undefined}

Keep single-\/ or double-\/quotes in the result.

{\bfseries{Example}}


\begin{DoxyCode}{0}
\DoxyCodeLine{split('a."{}b.c.d"{}.e');}
\DoxyCodeLine{//=> ['a', 'b.c.d', 'e']}
\DoxyCodeLine{}
\DoxyCodeLine{split('a."{}b.c.d"{}.e', \{keepQuotes: true\});}
\DoxyCodeLine{//=> ['a', '"{}b.c.d"{}', 'e']}
\DoxyCodeLine{}
\DoxyCodeLine{split('a.\(\backslash\)'b.c.d\(\backslash\)'.e', \{keepQuotes: true\});}
\DoxyCodeLine{//=> ['a', '\(\backslash\)'b.c.d\(\backslash\)'', 'e'] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28669}{}\doxysubsection{options.\+keep\+Double\+Quotes}\label{md_sfcode_node_modules_split_string_README_autotoc_md28669}
{\bfseries{Type}}\+: {\ttfamily boolean}

{\bfseries{Default}}\+: {\ttfamily undefined}

Keep double-\/quotes in the result.

{\bfseries{Example}}


\begin{DoxyCode}{0}
\DoxyCodeLine{split('a."{}b.c.d"{}.e');}
\DoxyCodeLine{//=> ['a', 'b.c.d', 'e']}
\DoxyCodeLine{}
\DoxyCodeLine{split('a."{}b.c.d"{}.e', \{keepDoubleQuotes: true\});}
\DoxyCodeLine{//=> ['a', '"{}b.c.d"{}', 'e'] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28670}{}\doxysubsection{options.\+keep\+Single\+Quotes}\label{md_sfcode_node_modules_split_string_README_autotoc_md28670}
{\bfseries{Type}}\+: {\ttfamily boolean}

{\bfseries{Default}}\+: {\ttfamily undefined}

Keep single-\/quotes in the result.

{\bfseries{Example}}


\begin{DoxyCode}{0}
\DoxyCodeLine{split('a.\(\backslash\)'b.c.d\(\backslash\)'.e');}
\DoxyCodeLine{//=> ['a', 'b.c.d', 'e']}
\DoxyCodeLine{}
\DoxyCodeLine{split('a.\(\backslash\)'b.c.d\(\backslash\)'.e', \{keepSingleQuotes: true\});}
\DoxyCodeLine{//=> ['a', '\(\backslash\)'b.c.d\(\backslash\)'', 'e'] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28671}{}\doxysection{Customizer}\label{md_sfcode_node_modules_split_string_README_autotoc_md28671}
{\bfseries{Type}}\+: {\ttfamily function}

{\bfseries{Default}}\+: {\ttfamily undefined}

Pass a function as the last argument to customize how tokens are added to the array.

{\bfseries{Example}}


\begin{DoxyCode}{0}
\DoxyCodeLine{var arr = split('a.b', function(tok) \{}
\DoxyCodeLine{  if (tok.arr[tok.arr.length -\/ 1] === 'a') \{}
\DoxyCodeLine{    tok.split = false;}
\DoxyCodeLine{  \}}
\DoxyCodeLine{\});}
\DoxyCodeLine{console.log(arr);}
\DoxyCodeLine{//=> ['a.b'] }

\end{DoxyCode}


{\bfseries{Properties}}

The {\ttfamily tok} object has the following properties\+:


\begin{DoxyItemize}
\item {\ttfamily tok.\+val} (string) The current value about to be pushed onto the result array
\item {\ttfamily tok.\+idx} (number) the current index in the string
\item {\ttfamily tok.\+str} (string) the entire string
\item {\ttfamily tok.\+arr} (array) the result array
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28672}{}\doxysection{Release history}\label{md_sfcode_node_modules_split_string_README_autotoc_md28672}
\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28673}{}\doxysubsection{v3.\+0.\+0 -\/ 2017-\/06-\/17}\label{md_sfcode_node_modules_split_string_README_autotoc_md28673}
{\bfseries{Added}}


\begin{DoxyItemize}
\item adds support for brackets
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28674}{}\doxysection{About}\label{md_sfcode_node_modules_split_string_README_autotoc_md28674}
$<$details$>$

{\bfseries{Contributing}} 

Pull requests and stars are always welcome. For bugs and feature requests, \href{../../issues/new}{\texttt{ please create an issue}}.

$<$/details$>$

$<$details$>$

{\bfseries{Running Tests}} 

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install \&\& npm test }

\end{DoxyCode}


$<$/details$>$

$<$details$>$

{\bfseries{Building docs}} 

\+\_\+(This project\textquotesingle{}s readme.\+md is generated by \href{https://github.com/verbose/verb-generate-readme}{\texttt{ verb}}, please don\textquotesingle{}t edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)\+\_\+

To generate the readme, run the following command\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install -\/g verbose/verb\#dev verb-\/generate-\/readme \&\& verb }

\end{DoxyCode}


$<$/details$>$\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28675}{}\doxysubsection{Related projects}\label{md_sfcode_node_modules_split_string_README_autotoc_md28675}
You might also be interested in these projects\+:


\begin{DoxyItemize}
\item \href{https://www.npmjs.com/package/deromanize}{\texttt{ deromanize}}\+: Convert roman numerals to arabic numbers (useful for books, outlines, documentation, slide decks, etc) $\vert$ \mbox{[}homepage\mbox{]}(\href{https://github.com/jonschlinkert/deromanize}{\texttt{ https\+://github.\+com/jonschlinkert/deromanize}} \char`\"{}\+Convert roman numerals to arabic numbers (useful for books, outlines, documentation, slide decks, etc)\char`\"{})
\item \href{https://www.npmjs.com/package/randomatic}{\texttt{ randomatic}}\+: Generate randomized strings of a specified length using simple character sequences. The original generate-\/password. $\vert$ \href{https://github.com/jonschlinkert/randomatic}{\texttt{ homepage}}
\item \href{https://www.npmjs.com/package/repeat-string}{\texttt{ repeat-\/string}}\+: Repeat the given string n times. Fastest implementation for repeating a string. $\vert$ \href{https://github.com/jonschlinkert/repeat-string}{\texttt{ homepage}}
\item \href{https://www.npmjs.com/package/romanize}{\texttt{ romanize}}\+: Convert numbers to roman numerals (useful for books, outlines, documentation, slide decks, etc) $\vert$ \mbox{[}homepage\mbox{]}(\href{https://github.com/jonschlinkert/romanize}{\texttt{ https\+://github.\+com/jonschlinkert/romanize}} \char`\"{}\+Convert numbers to roman numerals (useful for books, outlines, documentation, slide decks, etc)\char`\"{})
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28676}{}\doxysubsection{Contributors}\label{md_sfcode_node_modules_split_string_README_autotoc_md28676}
\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{2}{|X[-1]}|}
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\bfseries{Commits}}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\bfseries{Contributor}}    }\\\cline{1-2}
\endfirsthead
\hline
\endfoot
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\bfseries{Commits}}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\bfseries{Contributor}}    }\\\cline{1-2}
\endhead
28   &\href{https://github.com/jonschlinkert}{\texttt{ jonschlinkert}}    \\\cline{1-2}
9   &\href{https://github.com/doowb}{\texttt{ doowb}}   \\\cline{1-2}
\end{longtabu}
\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28677}{}\doxysubsection{Author}\label{md_sfcode_node_modules_split_string_README_autotoc_md28677}
{\bfseries{Jon Schlinkert}}


\begin{DoxyItemize}
\item \href{https://github.com/jonschlinkert}{\texttt{ github/jonschlinkert}}
\item \href{https://twitter.com/jonschlinkert}{\texttt{ twitter/jonschlinkert}}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_split_string_README_autotoc_md28678}{}\doxysubsection{License}\label{md_sfcode_node_modules_split_string_README_autotoc_md28678}
Copyright © 2017, \href{https://github.com/jonschlinkert}{\texttt{ Jon Schlinkert}}. Released under the \mbox{[}MIT License\mbox{]}(LICENSE).

\DoxyHorRuler{0}


{\itshape This file was generated by \href{https://github.com/verbose/verb-generate-readme}{\texttt{ verb-\/generate-\/readme}}, v0.\+6.\+0, on November 19, 2017.} 