Skip to content

(regex)

regular expression literals

clojure
(regex pattern? flags?)

Where:

  1. pattern: the regex pattern (the content between the slashes) *
  2. flags: the regex flags (e.g., g, i, m) *

Examples

Find global regex patterns that may need the 'u' flag for Unicode support.

clojure
(regex _ g)

Selects in lines { 1 } but not in { 2, 1 }:

typescript
const pattern = /\w+/g
const unicodeSafe = /\w+/gu
const simple = /\w+/

Locate case-insensitive email validation regexes for security audit.

clojure
(regex /email|@/ i)

Selects in lines { 1 } but not in { 2, 3 }:

typescript
const emailRegex = /[\w.]+@[\w.]+/i
const urlRegex = /https?:\/\//i
const strictEmail = /^[\w.]+@[\w.]+$/

Find regexes matching specific patterns to replace with named groups.

clojure
(regex /\(\?:/)

Selects in lines { 1 } but not in { 2, 3 }:

typescript
const nonCapturing = /(?:foo|bar)/
const capturing = /(foo|bar)/
const named = /(?<word>foo|bar)/

Arguments

pattern

• String • Pattern • Identifier

Does NOT support: CompositionFree-form SelectionRefinementReplacement

flags

• Identifier • String • Pattern

Does NOT support: CompositionFree-form SelectionRefinementReplacement

Copyright © 2022-present Semantic Works, Inc.