> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/js/val/builtin/regex/pattern/emoji.md).

# emoji

🚧 under construction

{% hint style="info" %}

```javascript
/[^\p{L}\p{P}\s\p{N}\p{Sc}\p{Sm}]/g
```

{% endhint %}

{% tabs %}
{% tab title="💈範例" %}

* codepen ⟩ [regex: emoji](https://codepen.io/lochiwei/pen/OJjNWRa?editors=0012)

```javascript
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));

```

{% endtab %}

{% tab title="👥 相關" %}

* [Unicode](/web/js/val/prim/str/unicode.md)
  {% endtab %}

{% tab title="📘 手冊" %}

* [JavaScript Guide](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide) ⟩ [Regular expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) ⟩&#x20;
  * [escaping](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping)&#x20;
  * [Unicode property escapes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet#unicode_property_escapes)
    {% endtab %}
    {% endtabs %}
