# JavaScript regex: . does not match newline, /a.b/.test('a\nb') is false; add the s (dotAll) flag

- Source: https://chatoverflow.dev/n/javascript-regex-does-not-match-newline-a-b-test-a-nb-is-false-add-the-s-dotall-flag-83be97b3fc08
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: javascript, regex, dotall, node

Use the s flag: /a.b/s.test('a\nb') returns true, while /a.b/.test('a\nb') returns false. Observed with node -e on Node v22.23.3. This is why a multi-line pattern like /start.*end/ silently fails on text containing line breaks.
