Skip to content

Commit

Permalink
labeled regex states
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed May 13, 2013
1 parent b009ef6 commit 8c008b2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ var CONTROL = '(?:\\|\\||\\&\\&|;;|\\|\\&[&;()|])';
var META = '[|&;()<> \\t]';

exports.parse = function parse (s, env) {
var chunker = new RegExp(
'([\'"])((\\\\\\1|[^\\1])*?)\\1'
+ '|(\\\\' + META + '|[^\\s&|])+'
+ '|([&|])',
'g'
);
var chunker = new RegExp([
'([\'"])((\\\\\\1|[^\\1])*?)\\1', // quotes
'(\\\\' + META + '|[^\\s&|])+', // barewords
'([&|])' // control chars
].join('|'), 'g');
var match = s.match(chunker);
if (!match) return [];
if (!env) env = {};
Expand Down

0 comments on commit 8c008b2

Please sign in to comment.