---
title: Tokenize a string with escaping
id: 594faaab4e2a8626833e9c3d
challengeType: 5
---
## Description
 
Write a function or program that can split a string at each non-escaped occurrence of a separator character.
 
It should accept three input parameters:
 It should output a list of strings. Rules for splitting: Rules for escaping: Demonstrate that your function satisfies the following test-case:
  Given string one^|uno||three^^^^|four^^^|^cuatro|
 and using
  |
 as a separator and ^
 as escape character, your
  function should output the following array:
['one|uno', '', 'three^^', 'four^|quatro', '']## Instructions
tokenize is a function.
    testString: assert(typeof tokenize === 'function', 'tokenize is a function.');
  - text: tokenize should return an array.
    testString: assert(typeof tokenize('a', 'b', 'c') === 'object', 'tokenize should return an array.');
  - text: tokenize('one^|uno||three^^^^|four^^^|^cuatro|', '|', '^')  should return ['one|uno', '', 'three^^', 'four^|cuatro', '']")
    testString: assert.deepEqual(tokenize(testStr1, '|', '^'), res1, "tokenize('one^|uno||three^^^^|four^^^|^cuatro|', '|', '^')  should return ['one|uno', '', 'three^^', 'four^|cuatro', '']");
  - text: tokenize('a@&bcd&ef&&@@hi', '&', '@') should return ['a&bcd', 'ef', '', '@hi']
    testString: assert.deepEqual(tokenize(testStr2, '&', '@'), res2, 'tokenize("a@&bcd&ef&&@@hi", "&", "@") should return ["a&bcd", "ef", "", "@hi"]');
```