mirror of https://github.com/jkjoy/sunpeiwen.git
17 lines
422 B
JavaScript
17 lines
422 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
/**
|
|
* Escapes regexp special chars
|
|
*/
|
|
function escapeRegExp(str) {
|
|
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
|
}
|
|
exports.escapeRegExp = escapeRegExp;
|
|
/**
|
|
* Trim trailing char
|
|
*/
|
|
function chomp(str, char) {
|
|
return str.replace(new RegExp(escapeRegExp(char) + '+$'), '');
|
|
}
|
|
exports.chomp = chomp;
|