Reputation: 14532
How would I go about and remove the listInfo prototype and logInfo object from the code bellow.
My problem is with the listInfo prototype where I can't seem to find a way to remove the closing bracket. Everything else is easy to find and remove.
var ePlug = (function (undefined) {
var logInfo, logErrors, logWarnings, hasError, version;
function ePlug(options) {
this.version = "0.1 Alpha";
this.logInfo = [];
this.logErrors = [];
this.logWarnings = [];
this.logInfo.push('Setting options start.');
options = options || {};
this.validate(options.one, 'string', 'one provided is not valid.');
this.validate(options.two, 'boolean', 'two provided is not valid.');
if(this.hasError !== true) {
options.one = typeof options.one === 'string' ? options.one : 'string';
options.two = typeof options.two === 'boolean' ? options.two : true;
this.logInfo.push('Setting options end.');
this.options = options;
}
else {
this.logErrors.push('Setting options error.');
}
}
ePlug.prototype.listInfo = function () {
return this.logg(this.logInfo);
};
ePlug.prototype.listErrors = function () {
return this.logg(this.logErrors);
};
ePlug.prototype.listWarnings = function () {
return this.logg(this.logWarnings);
};
ePlug.prototype.logg = function (what) {
if(typeof window.console === 'undefined') {
alert(what);
}
else {
console.log(what);
}
};
ePlug.prototype.init = function () {
if(this.hasError !== true) {
// start here
}
};
return ePlug;
})();
var eOpt = (function () {
function options() { return {}; }
return options;
})();
eOpt.one = 'test';
eOpt.two = false;
var ePlug = new ePlug(eOpt);
ePlug.init();
I want to be able to remove the code bellow
ePlug.prototype.listInfo = function () {
return this.logg(this.logInfo);
};
So far I can only remove the first two lines.
I have no idea how to go about removing the last line };
Upvotes: 0
Views: 58
Reputation: 3756
Code for GNU sed:
sed '/ePlug.prototype.listInfo = function () {/, /};/d' file
$cat file var ePlug = (function (undefined) { var logInfo, logErrors, logWarnings, hasError, version; function ePlug(options) { this.version = "0.1 Alpha"; this.logInfo = []; this.logErrors = []; this.logWarnings = []; this.logInfo.push('Setting options start.'); options = options || {}; this.validate(options.one, 'string', 'one provided is not valid.'); this.validate(options.two, 'boolean', 'two provided is not valid.'); if(this.hasError !== true) { options.one = typeof options.one === 'string' ? options.one : 'string'; options.two = typeof options.two === 'boolean' ? options.two : true; this.logInfo.push('Setting options end.'); this.options = options; } else { this.logErrors.push('Setting options error.'); } } ePlug.prototype.listInfo = function () { return this.logg(this.logInfo); }; ePlug.prototype.listErrors = function () { return this.logg(this.logErrors); }; ePlug.prototype.listWarnings = function () { return this.logg(this.logWarnings); }; ePlug.prototype.logg = function (what) { if(typeof window.console === 'undefined') { alert(what); } else { console.log(what); } }; ePlug.prototype.init = function () { if(this.hasError !== true) { // start here } }; return ePlug; })(); var eOpt = (function () { function options() { return {}; } return options; })(); eOpt.one = 'test'; eOpt.two = false; var ePlug = new ePlug(eOpt); ePlug.init(); $sed '/ePlug.prototype.listInfo = function () {/, /};/d' file var ePlug = (function (undefined) { var logInfo, logErrors, logWarnings, hasError, version; function ePlug(options) { this.version = "0.1 Alpha"; this.logInfo = []; this.logErrors = []; this.logWarnings = []; this.logInfo.push('Setting options start.'); options = options || {}; this.validate(options.one, 'string', 'one provided is not valid.'); this.validate(options.two, 'boolean', 'two provided is not valid.'); if(this.hasError !== true) { options.one = typeof options.one === 'string' ? options.one : 'string'; options.two = typeof options.two === 'boolean' ? options.two : true; this.logInfo.push('Setting options end.'); this.options = options; } else { this.logErrors.push('Setting options error.'); } } ePlug.prototype.listErrors = function () { return this.logg(this.logErrors); }; ePlug.prototype.listWarnings = function () { return this.logg(this.logWarnings); }; ePlug.prototype.logg = function (what) { if(typeof window.console === 'undefined') { alert(what); } else { console.log(what); } }; ePlug.prototype.init = function () { if(this.hasError !== true) { // start here } }; return ePlug; })(); var eOpt = (function () { function options() { return {}; } return options; })(); eOpt.one = 'test'; eOpt.two = false; var ePlug = new ePlug(eOpt); ePlug.init();
Curly brackets {}
are not special characters in BRE.
Upvotes: 2