File & Path

Hidden File (Dotfile)

Matches Unix-style hidden files (dotfiles) like .gitignore or .env.

Try it in RegexPro →

Available in

JavaScript / ECMAScript code

jsJavaScript
const re = new RegExp("^\\.[^.\\s/\\\\][^/\\\\]*$", "");
const input = ".gitignore";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));

Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).

Pattern

regexengine-agnostic
^\.[^.\s/\\][^/\\]*$

Raw source: ^\.[^.\s/\\][^/\\]*$

How it works

`^\.` requires leading dot. `[^.\s/\\]` requires the next character to not be another dot, whitespace, or slash. `[^/\\]*$` allows any additional non-slash characters.

Examples

Input

.gitignore

Matches

  • .gitignore

Input

.env.local

Matches

  • .env.local

Input

..

No match

Common use cases

  • File system tools
  • Git utilities
  • Config discovery

Related patterns