Regex \w — Match a Word Character

\w matches a single word character — [A-Za-z0-9_] in ASCII mode. It is extended in Unicode mode. Example: /\w/ on "foo_bar" matches f, o, o, _, b, a, r.

Open the interactive DevRef Hub tool →

Key facts

Token\w
ASCII match[A-Za-z0-9_]
Negation\W
Example/\w/ matches f o o _ b a r

Frequently asked questions

What does \w match?

A word character: [A-Za-z0-9_] in ASCII mode.

Does \w include the underscore?

Yes, _ is part of \w.

Related pages

Regex \w — Word Character is part of DevRef Hub on GOAT Lab — a free reference you can use without signing up, and it works offline. Open the tool above for any custom value.

Advertise

Part of GOAT Lab — 26 free, browser-based science, engineering and developer tools. No sign-up.