From ad05e316ac96ae6fe0110d064e9d50e4bfc63fb5 Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Tue, 21 May 2024 16:31:50 +0530 Subject: [PATCH 1/3] docs(regexp): update module example to get full jsr score --- regexp/escape.ts | 5 +++++ regexp/mod.ts | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/regexp/escape.ts b/regexp/escape.ts index 7be38846f714..c48ddcf1ab8a 100644 --- a/regexp/escape.ts +++ b/regexp/escape.ts @@ -1,6 +1,11 @@ // 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. +* @module +*/ + // // For future forward-compatibility with regexp `v` flag, reservedCharMap is // // autogenerated from the ClassSetReservedDoublePunctuator, // // ClassSetSyntaxCharacter, and ClassSetReservedPunctuator categories in the diff --git a/regexp/mod.ts b/regexp/mod.ts index cab2ada81b5b..fe5369c307fe 100644 --- a/regexp/mod.ts +++ b/regexp/mod.ts @@ -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"; From 65b1a488d34f5a0291b58d5a6bae67d1e832d8da Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Tue, 21 May 2024 16:31:50 +0530 Subject: [PATCH 2/3] docs(regexp): update module example to get full jsr score --- regexp/escape.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/regexp/escape.ts b/regexp/escape.ts index c48ddcf1ab8a..c48f09603177 100644 --- a/regexp/escape.ts +++ b/regexp/escape.ts @@ -2,9 +2,9 @@ // This module is browser compatible. /** -* This module contains functions to escape strings for use in regular expressions. -* @module -*/ + * This module contains functions to escape strings for use in regular expressions. + * @module + */ // // For future forward-compatibility with regexp `v` flag, reservedCharMap is // // autogenerated from the ClassSetReservedDoublePunctuator, From b8495a2fd2cefb2a16aa535226be31c8b1efb56b Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Tue, 21 May 2024 19:27:37 +0530 Subject: [PATCH 3/3] add example to escape module --- regexp/escape.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/regexp/escape.ts b/regexp/escape.ts index c48f09603177..da1a8bc98476 100644 --- a/regexp/escape.ts +++ b/regexp/escape.ts @@ -3,6 +3,19 @@ /** * 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 */ @@ -32,7 +45,7 @@ const reservedCharMap = { "&": "\\x26", "!": "\\x21", "#": "\\x23", - "$": "\\$", + $: "\\$", "%": "\\x25", "*": "\\*", "+": "\\+",