# emoji

{% 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](https://lochiwei.gitbook.io/web/js/val/prim/str/unicode "mention")
  {% 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lochiwei.gitbook.io/web/js/val/builtin/regex/pattern/emoji.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
