---
# System prepended metadata

title: '正規表達式(Regular Expression, regex)'
tags: [RegExp, Sharing, 'A30:換你來手刻']

---

###### tags:`Sharing` `RegExp` `A30:換你來手刻` 

# 正規表達式(Regular Expression, regex)

![](https://i.imgur.com/dIj85kr.png)

:::danger
無法理解最後的 "i" 代表的意思?
`const regex = new RegExp(searchInput.value, 'i')` 
:::

:::info
:point_right: [JavaScript RegExp Reference](https://www.w3schools.com/jsref/jsref_obj_regexp.asp)

參考上方網頁得知 "i" 為修飾符 (Modifier)，代表的內容為搜索值不分區域大小寫皆會成立。


| Modifier | Description                       |
|:--------:| --------------------------------- |
|    i     | Perform case-insensitive matching |
|    g     | Perform a global match (find all matches rather than stopping after the first match) |
|    m     | Perform multiline matching |


![](https://i.imgur.com/ua58zh4.png)
:::

:::success
case-insensitive >> case 為字母意思，insensitive 不敏感，合併起來為不分區域大小寫。下方為反向解說
![](https://i.imgur.com/vE2xNSI.png)
:::

:::info
其他參考:
[[JS] 正則表達式(Regular Expression, regex)](https://pjchender.github.io/2017/09/26/js-%E6%AD%A3%E5%89%87%E8%A1%A8%E9%81%94%E5%BC%8F-regular-expression-regex/)
:::







