๐Ÿ˜€emoji

๐Ÿšง under construction

/[^\p{L}\p{P}\s\p{N}\p{Sc}\p{Sm}]/g
const {log} = console;

let input = `
   ๐Ÿ––๐Ÿฝ ๐Ÿ‘‹๐Ÿฝ ๐Ÿค™๐Ÿฝ ๐Ÿ’ช๐Ÿฝ ๐Ÿ–•๐Ÿฝ โœ๐Ÿฝ ๐Ÿคณ๐Ÿฝ ๐Ÿ’…๐Ÿฝ ๐Ÿ‘‚๐Ÿฝ ๐Ÿ‘ƒ๐Ÿฝ้€™ไบ›ๆ˜ฏไธญๆ–‡ๅญ—๏ผŒthis is english.
  ไธปไบบ๏ผŒๆ˜Žๅคฉๆœ‰2ไปถไบ‹๏ผš
  ๐Ÿ’ณ Google One ๆœˆ่ฒป (US$2)ใ€๐Ÿ“”Paper Pro ($190/ๅŠๅนด)๏ผŒๅ ฑๅ‘ŠๅฎŒ็•ขใ€‚
  10/5 ~ 10/18 ไบŒ็ดš่ญฆๆˆ’ใ€‚
  10/10 ~ 11/11 ้›™ๅๅœ‹ๆ…ถใ€‚
`;

const dateRange = /(\d{1,2})\/(\d{1,2})\s*([~-])\s*(\d{1,2})\/(\d{1,2})/g;
const usd = /us\$(\d+)/gi;
const fee = /\$?(\d+)\/([^\w\s),]+)/gu;

/*
    - L : Letters
    - P : Punctuation
    - N : Number
    
    - Sc: Symbol (currency) - "$"
    - Sm: Symbol (math)     - "~"
    
    - Pc: Punctuation (connector) - underscore '_' and similar characters,
    - Po: Punctuation (others)    - ?
*/

// โญ๏ธ ้€™ๅ€‹ไผผไนŽๅฏไปฅ็”จไพ†ๆ‰พ emoji
const emojis = /[^\p{L}\p{P}\s\p{N}\p{Sc}\p{Sm}]/gu;  // โญ๏ธ "/u" flag

// ---------- test run ----------

let result = input
  .replace(emojis, '')
  .replace(/[ ]+/g, ' ')
  // 10/5 ~ 10/18 -> 10 ๆœˆ 5 ๆ—ฅๅˆฐ 10 ๆœˆ 18 ๆ—ฅ
  .replace(dateRange, "$1 ๆœˆ $2 ๆ—ฅๅˆฐ $4 ๆœˆ $5 ๆ—ฅ") 
  .replace(usd, "$1 ็พŽๅ…ƒ") // US$345 -> 345 ็พŽๅ…ƒ
  .replace(fee, "ๆฏ$2 $1 ๅ…ƒ"); // 190/ๅŠๅนด -> ๆฏๅŠๅนด 190 ๅ…ƒ

[
  result,  
  // input.replace(fee, 'ๆฏ$2 $1 ๅ…ƒ'),
    
].forEach(x => log(x));

Last updated