George Mason University Antonin Scalia Law School

Remove Periods from Degrees

For example, replace J.D. or L.L.M to JD or LLM.

Here’s the JavaScript method:

<script>
function removePeriods() {
var str = document.getElementById("c_degrees").innerHTML;
var res = str.replace(/\./g, "");
document.getElementById("c_degrees").innerHTML = res;
}
window.onload = removePeriods;
</script>

To do it in MODX, create a chunk called FixDegrees:

A.B.:AB,A.M.:AM,B.A.:BA,B.B.A.:BBA,B.C.:BC,B.Com.:BCom,B.E.E.:BEE,B.I.E.:BIE,B.F.A.,BFA:B.L.:BL,B.M.:BM,B.M.E.:BME,B.S.:BS,B.S.E.:BSE,B.S.E.E.:BSEE,D.Jur.:DJur,D.O.:DO,J.D.:JD,J.S.D.:JSD,J.S.P.:JSP,Ed.D.:EdD,Ed.S.:EdS,LL.B.:LLB,LL.D.:LLD,LL.L.:LLL,LL.M.:LLM,M.A.:MA,M.A.S.:MAS,M.B.A.:MBA,M.Ed:MEd,M.Fc.:MFc,M.L.I.S.:MLIS,M.L.S.:MLS,M.D.:MD,M.Ed.:MEd,M.S.:MS,M.Sc.:MSc,M.S.E.E.:MSEE,M.S.L.S.:MSLS,M.T.:MT,P.G.C.E.:PGCE,Ph.D.:PhD,Cert. of Legal Educ.:Cert of Legal Educ,M.P.P.:MPP,S.J.D.:SLD

Than create a snippet called ReplaceDegrees:

<?php
$find = array();
$replace = array();

$line = $modx->getChunk('FixDegrees');
$pairs = array_map('trim', explode(',', $line));
foreach($pairs as $pair) {
if (strpos($pair, ':') === false) {
$pair = $pair . ':';
}
$couple = array_map('trim', explode(':', $pair));
$find[] = $couple[0];
$replace[] = $couple[1];
}
return str_replace($find, $replace , $input);

Call the snippet in the template:

[[*bio:ReplaceDegrees]]