function scapeRegex(text) {
    var pattern = new RegExp('[-\/\\^$*+?.()|[\]{}]', 'g');
    return text.replace(pattern, '\\$&');
}