3 var toRegex = require('to-regex');
4 var regexNot = require('regex-not');
8 * Get the last element from `array`
9 * @param {Array} `array`
13 exports.last = function(arr) {
14 return arr[arr.length - 1];
18 * Create and cache regex to use for text nodes
21 exports.createRegex = function(pattern, include) {
22 if (cached) return cached;
23 var opts = {contains: true, strictClose: false};
24 var not = regexNot.create(pattern, opts);
27 if (typeof include === 'string') {
28 re = toRegex('^(?:' + include + '|' + not + ')', opts);
30 re = toRegex(not, opts);