Skip to content

(str)

string literals

clojure
(str val?)

Where:

  1. val: string value to match *

Matching:

  1. single-quoted strings, e.g. 'hello'
  2. double-quoted strings, e.g. "hello"
  3. template string fragments, e.g. `hello`
  4. JSX text content, e.g. <div>text</div>

Behavior

  • Matches string literals in any quote style.
  • Also matches non-empty JSX text content.
  • Template string fragments within backticks are matched, but not the template expressions.

Examples

Find hardcoded API endpoints before moving them to configuration.

clojure
(str /https?:\/\/.+/)

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

typescript
fetch('https://api.example.com/users')
fetch(API_URL + '/users')
const url = 'http://localhost:3000'

Locate console.log statements with specific debug prefixes for cleanup.

clojure
(call (mem log console) (arg 1 (str /^\[DEBUG\]/)))

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

typescript
console.log('[DEBUG] User loaded', user)
console.log('[INFO] Server started')
console.error('[DEBUG] Failed')

Find JSX components with hardcoded text before internationalization.

clojure
(jsx _ _ (child _ (str /english/i)))

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

typescript
<div>English text here</div>
<span>Translated content</span>
<p>This is in English</p>

Arguments

val

• Identifier • String • Pattern

Does NOT support: CompositionFree-form SelectionRefinementReplacement

Copyright © 2022-present Semantic Works, Inc.