Skip to content

(:capture)

captures a matched value to reference in (:replace) substitutions

clojure
(:capture name val?)

Where:

  1. name: the name to reference this capture (used as $name) *
  2. val: the value to capture *

Behavior

  • Captured values are referenced in substitution strings using $name syntax.

Examples

Capture the first argument to prepend it elsewhere in a transformation.

clojure
(call process
  (arg 1
    (:and
      (:capture firstArg (str))
      (:replace _ ""before", $firstArg"))))

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

typescript
process("data")

Capture from one argument to use in replacing another argument.

clojure
(call fetch
  (:and
    (arg 1 (:capture endpoint (str)))
    (arg 2 (:replace _ "$endpoint_config"))))

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

typescript
fetch("/users", oldConfig)

Capture a list of nodes by using (:into) to span the entire range.

clojure
(:and
  (call log (arg 1 (:replace _ "$params")))
  (call log (arg 2.. (:capture params (:into)))))

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

typescript
log(first, second, third)

Use captured identifier name to generate a prefixed version.

clojure
(call bootstrap (arg 1 (:replace (id /(?<name>.+)/) "init_$name")))

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

typescript
bootstrap(component)
bootstrap(service)

Arguments

name

• Identifier

Does NOT support: CompositionFree-form SelectionRefinementReplacement

val

inherit

Copyright © 2022-present Semantic Works, Inc.