Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 30x | const selectorSafe = (string) => { // Normalise to separate diacritics from their base characters as "marks" // then strip out all marks. return string.normalize('NFKD')?.replace(/\p{M}/gu, '') // Then swap out any non-letter/number characters (Also ignore - and _) for `_` ?.replace(/[^\p{L}\p{N}\-_]/gu, '_'); }; export default selectorSafe; /* * Should transform as follows: * %%&&||()_-*^%$£"!:;@'~#<>/??|\ --> _________-____________________ * étéaoûtçapère; --> eteaoutcapere_ * Wörtertschüss; --> wortertschuss_ * mañanaángel'brødfråłzaźlepięćkuşgöz`tŷ --> mananaangel_brødfrałzazlepieckusgoz_ty * æøß --> æøß * How do we handle numbers 00!1 --> how_do_we_handle_numbers_00_1 * This is a normal case --> this_is_a_normal_case */ |