wiki/content/20201110094807-javascript_regexp_s_flag.md

23 lines
369 B
Markdown
Raw Normal View History

2024-05-06 20:40:05 +00:00
---
2024-10-29 18:27:12 +00:00
date: 2020-11-10
2024-05-06 20:40:05 +00:00
id: 8bf1886a-0754-467f-a441-cb21bccfbd46
title: JavaScript RegExp /s flag
---
# Introduction
The dot (.) in regular expressions doesn't match line terminator
characters:
``` javascript
console.log(/%.$/.test('\n')) // false
```
The `/s` expression (dotAll) flag fixes this.
# Syntax
``` javascript
console.log(/^.$/s.test("\n")); // true
```