Skip to content

Instantly share code, notes, and snippets.

@stuartbreckenridge
Created November 4, 2021 03:27
Show Gist options
  • Save stuartbreckenridge/b513097ae199d153824461478c555dfd to your computer and use it in GitHub Desktop.
Save stuartbreckenridge/b513097ae199d153824461478c555dfd to your computer and use it in GitHub Desktop.
Expand abbreviated bus stop names
extension String {
func expandName() -> String {
return self
.replacingOccurrences(of: "\\bA'space\\b", with: "Aerospace", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bAbly\\b", with: "Assembly", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bAc\\b", with: "Academy", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bAcad\\b", with: "Academy", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bAdm\\b", with: "Administration", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bAdvent\\b", with: "Adventist", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bAft\\b", with: "After", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bAMK\\b", with: "Ang Mo Kio", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bApt\\b", with: "Apartment", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bApts\\b", with: "Apartments", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bArchitect\\b", with: "Architecture", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bAssn\\b", with: "Association", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bAve\\b", with: "Avenue", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bBef\\b", with: "Before", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bBet\\b", with: "Between", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bBiz\\b", with: "Business", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bBKE\\b", with: "Bukit Timah Expressway", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bBldg\\b", with: "Building", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bBlk\\b", with: "Block", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bBlks\\b", with: "Blocks", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bBlvd\\b", with: "Boluevard", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bBr\\b", with: "Branch", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bBros\\b", with: "Brothers", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bBt\\b", with: "Bukit", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bB-P\\b", with: "Bible-Presbyterian", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bC'wealth\\b", with: "Commonwealth", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bC&I\\b", with: "Communication and Information", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCano\\b", with: "Canossian", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCath\\b", with: "Cathedral", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCC\\b", with: "Community Centre", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCCK\\b", with: "Choa Chu Kang", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCD\\b", with: "Civil Defence", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCEE\\b", with: "Civil and Environmental Engineering", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCemy\\b", with: "Cemetary", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCh\\b", with: "Church", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCheckpt\\b", with: "Checkpoint", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bChild\\b", with: "Children", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bChr\\b", with: "Christian", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCl\\b", with: "Close", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bClubhse\\b", with: "Clubhouse", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCmty\\b", with: "Community", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bColl\\b", with: "College", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bComsn\\b", with: "Commission", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCondo\\b", with: "Condominium", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bConstrn\\b", with: "Construction", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCorp\\b", with: "Corporation", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCP\\b", with: "Car Park", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCplx\\b", with: "Complex", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCres\\b", with: "Crescent", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCt\\b", with: "Court", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCTE\\b", with: "Central Expressway", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCtr\\b", with: "Centre", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bCtrl\\b", with: "Central", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bDevt\\b", with: "Development", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bDistripk\\b", with: "Distripark", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bDP\\b", with: "Distripark", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bDiv\\b", with: "Division", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bDr\\b", with: "Drive", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bDrv\\b", with: "Driving", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\b E \\b", with: "Elizabeth", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bE.C.\\b", with: "East Coast", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bEng\\b", with: "English", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bEngrg\\b", with: "Engineering", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bEnv\\b", with: "Environment", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bEst\\b", with: "Estate", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bFab\\b", with: "Fabrication", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bFac\\b", with: "Faculty", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bFC\\b", with: "Food Centre", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bFty\\b", with: "Factory", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\b G \\b", with: "Gate", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bG.\\b", with: "Green", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bGdn\\b", with: "Garden", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bGdns\\b", with: "Gardens", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bGen\\b", with: "General", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bGovt\\b", with: "Government", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bGr\\b", with: "Grove", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bHme\\b", with: "Home", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bHosp\\b", with: "Hospital", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bHQ\\b", with: "Headquarters", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bHse\\b", with: "House", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bHts\\b", with: "Heights", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bInd\\b", with: "Industrial", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bInd\\b", with: "Industries", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bInsp\\b", with: "Inspection", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bInst\\b", with: "Institute", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bInstn\\b", with: "Insitution", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bInt\\b", with: "Interchange", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bIntl\\b", with: "International", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bJC\\b", with: "Junior College", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bJln\\b", with: "Jalan", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bJnr\\b", with: "Junior", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bK\\b", with: "Kaliamman", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bKg\\b", with: "Kampong", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bKJE\\b", with: "Kranji Expressway", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bKPE\\b", with: "Kallang – Paya Lebar Expressway", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bLib\\b", with: "Library", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bLk\\b", with: "Link", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bLor\\b", with: "Lorong", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bLP\\b", with: "Lamp Post", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bLT\\b", with: "Lecture Theatre", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bLtd\\b", with: "Limited", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bMed\\b", with: "Medical", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bMet\\b", with: "Metropolitan", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bMeth\\b", with: "Methodist", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bMfg\\b", with: "Manufacturing", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bMin\\b", with: "Ministry", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bMjd\\b", with: "Masjid", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bMkt\\b", with: "Market", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bMohd\\b", with: "Mohamed", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bMque\\b", with: "Mosque", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bMSCP\\b", with: "Multi Storey Car Park", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bMt\\b", with: "Mount", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bNatl\\b", with: "National", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bNo.\\b", with: "Number", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bNPC\\b", with: "Neighbourhood Police Centre", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bNth\\b", with: "North", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bOff\\b", with: "Office", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bOpp\\b", with: "Opposite", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bP/G\\b", with: "Playground", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bP/L\\b", with: "Private Limited", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bPIE\\b", with: "Pan Island Expressway", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bPk\\b", with: "Park", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bPl\\b", with: "Place", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bPlt\\b", with: "Plant", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bPO\\b", with: "Post Office", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bPoly\\b", with: "Polytechnic", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bPr\\b", with: "Primary", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bPresby\\b", with: "Presbyterian", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bProc\\b", with: "Processing", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bPt\\b", with: "Point", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bPTB\\b", with: "Passenger Terminal Building", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bPte\\b", with: "Private", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bRd\\b", with: "Road", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bReclam\\b", with: "Reclamation", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bReform\\b", with: "Reformative", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bReg\\b", with: "Regional", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bReh.\\b", with: "Rehabilitation", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bRehab\\b", with: "Rehabilitation", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bRel\\b", with: "Release", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bResvr\\b", with: "Reservoir", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bS Army\\b", with: "Salvation", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bS'goon\\b", with: "Serangoon", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bS'pore\\b", with: "Singapore", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bS Snr\\b", with: "Shibuya Senior", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bS.A.\\b", with: "Singapore Association", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bSBST\\b", with: "SBS Transit", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bSch\\b", with: "School", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bSci\\b", with: "Science", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bSec\\b", with: "Secondary", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bSg\\b", with: "Sungei", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bShop\\b", with: "Shopping", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bSLE\\b", with: "Seletar Expressway", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bSnr\\b", with: "Senior", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bSq\\b", with: "Square", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\b St \\b", with: " Street ", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\b St$", with: " Street", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bSt. \\b", with: "Saint ", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bSth\\b", with: "South", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bStn\\b", with: "Station", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bSvc\\b", with: "Service", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bSvcs\\b", with: "Services", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bSwim\\b", with: "Swimming", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bTec\\b", with: "Technology", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bTech\\b", with: "Technology", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bTemp\\b", with: "Temporary", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bTer\\b", with: "Terminal", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bTers\\b", with: "Terminals", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bTerr\\b", with: "Terrace", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bTg\\b", with: "Tanjong", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bTownhse\\b", with: "Townhouse", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bTp\\b", with: "Temple", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bTPE\\b", with: "Tampines Expressway", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bTrg\\b", with: "Training", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bTrspt\\b", with: "Transport", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bTwr\\b", with: "Tower", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bTwrs\\b", with: "Towers", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bUpp\\b", with: "Upper", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bV\\b", with: "Village", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bVeh\\b", with: "Vehicle", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bW’lands\\b", with: "Woodlands", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bWarehse\\b", with: "Warehouse", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bWk\\b", with: "Walk", options: [.regularExpression, .caseInsensitive])
.replacingOccurrences(of: "\\bWtr\\b", with: "Water", options: [.regularExpression, .caseInsensitive])
}
}
/* Tests
print("Downtown Stn".expandName())
print("Aft Zion Full Gospel Ch".expandName())
print("Opp Valley Pt".expandName())
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment