ws4kp/server/scripts/modules/utils/string.mjs

20 lines
475 B
JavaScript
Raw Normal View History

2022-11-22 22:19:10 +00:00
const locationCleanup = (input) => {
// regexes to run
const regexes = [
// "Chicago / West Chicago", removes before slash
2023-01-06 20:39:39 +00:00
/^[ A-Za-z]+ \/ /,
2022-11-22 22:19:10 +00:00
// "Chicago/Waukegan" removes before slash
2023-01-06 20:39:39 +00:00
/^[ A-Za-z]+\//,
2022-11-22 22:19:10 +00:00
// "Chicago, Chicago O'hare" removes before comma
2023-01-06 20:39:39 +00:00
/^[ A-Za-z]+, /,
2022-11-22 22:19:10 +00:00
];
// run all regexes
return regexes.reduce((value, regex) => value.replace(regex, ''), input);
};
export {
// eslint-disable-next-line import/prefer-default-export
locationCleanup,
};