mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
docs(regexp): update module example to get full jsr score (#4796)
This commit is contained in:
parent
78614676a1
commit
376f4da0de
@ -1,6 +1,24 @@
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
// This module is browser compatible.
|
||||
|
||||
/**
|
||||
* This module contains functions to escape strings for use in regular expressions.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { escape } from "@std/regexp/escape";
|
||||
* import { assertEquals, assertMatch, assertNotMatch } from "@std/assert";
|
||||
*
|
||||
* const re = new RegExp(`^${escape(".")}$`, "u");
|
||||
*
|
||||
* assertEquals("^\\.$", re.source);
|
||||
* assertMatch(".", re);
|
||||
* assertNotMatch("a", re);
|
||||
* ```
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
|
||||
// // For future forward-compatibility with regexp `v` flag, reservedCharMap is
|
||||
// // autogenerated from the ClassSetReservedDoublePunctuator,
|
||||
// // ClassSetSyntaxCharacter, and ClassSetReservedPunctuator categories in the
|
||||
@ -27,7 +45,7 @@ const reservedCharMap = {
|
||||
"&": "\\x26",
|
||||
"!": "\\x21",
|
||||
"#": "\\x23",
|
||||
"$": "\\$",
|
||||
$: "\\$",
|
||||
"%": "\\x25",
|
||||
"*": "\\*",
|
||||
"+": "\\+",
|
||||
|
@ -7,6 +7,18 @@
|
||||
* such as escaping text for interpolation into a regexp.
|
||||
*
|
||||
* @module
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { escape } from "@std/regexp";
|
||||
* import { assertEquals, assertMatch, assertNotMatch } from "@std/assert";
|
||||
*
|
||||
* const re = new RegExp(`^${escape(".")}$`, "u");
|
||||
*
|
||||
* assertEquals("^\\.$", re.source);
|
||||
* assertMatch(".", re);
|
||||
* assertNotMatch("a", re);
|
||||
* ```
|
||||
*/
|
||||
|
||||
export * from "./escape.ts";
|
||||
|
Loading…
Reference in New Issue
Block a user