cleanTerm method Null safety
- Term term
Cleans the term as follows:
- change all quote marks to single apostrophe +U0027;
- remove enclosing quote marks;
- hange all dashes to single standard hyphen;
- remove all characters except letters and numbers at end of term
Implementation
Term cleanTerm(Term term) => term
.toLowerCase()
// change all quote marks to single apostrophe +U0027
.replaceAll(RegExp('[\'"“”„‟’‘‛]+'), "'")
// remove enclosing quote marks
.replaceAll(RegExp(r"(^'+)|('+(?=$))"), '')
// change all dashes to single standard hyphen
.replaceAll(RegExp(r'[\-—]+'), '-')
// remove all characters except letters and numbers at end of term
.replaceAll(RegExp(r'[^0-9a-z](?=$)'), '')
.trim();