[\\s\\S]*?',
'gi');
function removeTags(html) {
var oldHtml;
// Remove tags
do {
oldHtml = html;
html = html.replace(tagOrComment, '');
} while (html !== oldHtml);
return html ;
}
// Remove trailing spaces before end of line
function removeEolSpaces(s) {
return s.replace(/\s\s*$/gm, "") ;
}
function processNonPrintableAscii(s) {
if(s == null || s.length == 0)
return "" ;
// Replace extended ascii characters with appropriate substitutes
// different types of space -> space
s = s.replace(/[\u0020\u00A0\u1680\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u205F\u3000]/g,' ') ;
s = s.replace(/[\u2018\u2019]/g,'\'') ; // left and right single quote -> apostrophe
s = s.replace(/[\u201C\u201D]/g,'\"') ; // left and right double quotes -> double quotes
s = s.replace(/[\u2012\u2013\u2014\u2015]/g,'-') ; // different types of dash -> hyphen
s = s.replace(/[\u2026]/g,'...') ; // horizontal ellipses -> 3 dots
// Remove non-printable ascii characters; but leave newline/carriage return
s = s.replace(/[^\x20-\x7E|\r\n]/g, '') ;
return s ;
}
function escapeXmlSpecialChars(s) {
if(s == null || s.length == 0)
return "" ;
// NOTE: replaceAll '&' must be first;
// otherwise it will replace & in & etc.
s = replaceAll(s, '&', '&') ;
s = replaceAll(s, '\'', ''') ;
s = replaceAll(s, '\"', '"') ;
s = replaceAll(s, '<', '<') ;
s = replaceAll(s, '>', '>') ;
return s ;
}
function restoreXmlSpecialChars(s) {
if(s == null || s.length == 0)
return "" ;
s = replaceAll(s, '&', '&') ;
s = replaceAll(s, ''', '\'') ;
s = replaceAll(s, '"', '\"') ;
s = replaceAll(s, '<', '<') ;
s = replaceAll(s, '>', '>') ;
return s ;
}
function replaceAll(s, search, replace) {
return s.split(search).join(replace) ;
}
function wordWrap(str, maxWidth) {
var newLineStr = "\n"; done = false; res = '';
while (str.length > maxWidth) {
found = false;
// Inserts new line at first whitespace of the line
for (i = maxWidth - 1; i >= 0; i--) {
if (testWhite(str.charAt(i))) {
res = res + [str.slice(0, i), newLineStr].join('');
str = str.slice(i + 1);
found = true;
break;
}
}
// Inserts new line at maxWidth position, the word is too long to wrap
if (!found) {
res += [str.slice(0, maxWidth), newLineStr].join('');
str = str.slice(maxWidth);
}
}
return res + str;
}
function testWhite(x) {
var white = new RegExp(/^\s$/);
return white.test(x.charAt(0));
};
StudentWire / Students