---
description: 🚧 under construction
---

# anchor

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

{% hint style="success" %}
<mark style="color:purple;">**anchors**</mark> match the <mark style="color:yellow;">**position**</mark>**&#x20;**<mark style="color:red;">**between**</mark>**&#x20;**<mark style="color:yellow;">**characters**</mark>, <mark style="color:red;">**not**</mark>**&#x20;**<mark style="color:yellow;">**the characters themselves**</mark>:exclamation:

```regex
^    beginning anchor    start of string/line
$    end anchor          end of string/line
\b   word boundary       position between \w\W or \W\w
                         (also matches start/end of line)
\B   non-word boundary   position between a \w\w or \W\W
```
{% endhint %}

{% tabs %}
{% tab title="💈範例" %}
```javascript
/cat/.test("concatenate")        // true
/\bcat\b/.test("concatenate")    // false
```
{% 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 %}
