Skip to content

Function: isGlobString() ​

isGlobString(inp): boolean

Tell whether a string is a glob pattern rather than a literal path: whether it has an unescaped *, a closed bracket class ([abc]), a closed brace group ({a,b}), an extglob (@(a|b), !(a)…), a regex-like group ((a|b)), a leading ! (a negation), or an unescaped ? (a wildcard of one character for Glob: 'a?b'). A character escaped with \ does not count. @param inp The string to test; an empty string or a value which is not a string gives false. @returns true when the string has glob syntax, false otherwise.

Parameters ​

inp ​

string

Returns ​

boolean

Example ​

typescript
import {isGlobString} from 'lakutata/utils'

console.log(isGlobString('src/**/*.ts'), isGlobString('src/{a,b}.ts'))
//true true
console.log(isGlobString('src/index.ts'), isGlobString('\\*.ts'), isGlobString('a?b'))
//false false true

Released under the MIT License.