> 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/anchor.md).

# anchor

🚧 under construction

[JS](/web/js.md) ⟩ [value](/web/js/val.md) ⟩ [object](/web/js/val/obj.md) ⟩ [regex](/web/js/val/builtin/regex.md) ⟩ [pattern](/web/js/val/builtin/regex/pattern.md) ⟩ 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 %}
