---
description: 🚧 under construction
---

# repeat

[JS](../../../..) ⟩ [value](../../..) ⟩ [object](../../../obj) ⟩ [regex](..) ⟩ [pattern]() ⟩ repeat

{% hint style="success" %}
```regex
         repeat   regex       matches
------------------------------------------------------
?	 0 ~ 1    colou?r     color colour
*        0 ~ ∞    b\w*        b be bee beer beers
+        1 ~ ∞    b\w+        be bee beer beers

{2,3}    2 ~ 3    b\w{2,3}    bee beer beers
{3}      3
{3,}     3 ~ ∞

// quantifiers are normally greedy (match as much as possible)
// when followed by ? they become lazy (match as little as possible)
+?       lazy     b\w+?       be bee beer beers         (as few as possible)
                              ╰╯ ╰╯  ╰╯   ╰╯
```

:u6307: <mark style="color:yellow;">**synonyms**</mark>： "<mark style="color:purple;">**quantifier**</mark>", "<mark style="color:purple;">**repetition operator**</mark>"
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="warning" %}
When using a <mark style="color:purple;">**repetition operator**</mark>, consider the [<mark style="color:yellow;">**lazy**</mark>](repeat/greedy-vs.-lazy) variant <mark style="color:red;">**first**</mark>.
{% endhint %}
{% endtab %}

{% tab title="💈範例" %}
```javascript
// code
```
{% endtab %}

{% tab title="📗 參考" %}
* [ ] Eloquent JavaScript ⟩ Regular Expressions ⟩ [Sets of Characters](https://eloquentjavascript.net/09_regexp.html#h_8EFR0DU1xd)
* [ ] [Regular Expression Quick Reference](http://regexrenamer.sourceforge.net/help/regex_quickref.html)
{% endtab %}
{% endtabs %}
