Skip to content

Instantly share code, notes, and snippets.

@justinkelly
Last active August 29, 2015 14:20
Show Gist options
  • Save justinkelly/a392483775679377f869 to your computer and use it in GitHub Desktop.
Save justinkelly/a392483775679377f869 to your computer and use it in GitHub Desktop.
Atom.io text replace for ReseachBank
Date.prototype.yyyymmdd = function() {
var yyyy = this.getFullYear().toString();
var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based
var dd = this.getDate().toString();
return yyyy + (mm[1]?mm:"0"+mm[0]) + (dd[1]?dd:"0"+dd[0]); // padding
};
d = new Date();
$date = d.yyyymmdd();
editor = atom.workspace.activePaneItem
$text = editor.getText();
$text = $text.replace(/20uu9999/g,$date);
$text = $text.replace(/\&\#xA9\;/g, '©');
$text = $text.replace(/\&\#x201C\;|\&\#x201D\;|\&\#x2019\;|\&\#x2018\;/gi, "'");
$text = $text.replace(/\&\#xD\;/g,' ');
$text = $text.replace(/ /g,' ');
$text = $text.replace(/ \</g,'<');
$text = $text.replace(/\> /g,'>');
editor.setText($text);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment