Regex $ — End of Line/String

$ is a zero-width anchor that matches the end of the input string, or the end of each line when the multiline (/m) flag is set. It consumes no characters.

Open the interactive DevRef Hub tool →

Key facts

Token$
TypeZero-width anchor
With /mMatches each line end
Example/$/ on "foo\nbar" → ["bar"]

Frequently asked questions

What does $ mean in regex?

It anchors a match to the end of the string (or line with /m).

Difference between $ and \z?

$ may match before a trailing newline; \z (where supported) matches the absolute end.

Related pages

Regex $ — End Anchor 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.