var isString = require('../is/string');

/**
 * Like trim.
 *
 * @param {string} string string
 * @return {string} boolean
 *
 * @example
 * var snu = require('s-node-utils');
 *
 * snu.string.chop('text');
 * //=> text
 *
 * snu.string.chop(' text ');
 * //=> text
 *
 * snu.string.chop('-text-');
 * //=> text
 */
module.exports = function(string) {
  if (!isString(string)) return '';
  var regex = /^[-_.\W\s]+|[-_.\W\s]+$/g;
  return string.trim().replace(regex, '');
};
