Registry / serialization / regx
library1.0.4jsnpmunverified

Tagged template string regular expression compiler. v1.0.4, last updated 2016 (stable, low maintenance). Parses multiline RegExp strings embedded in template literals, stripping comments and whitespace for readability. Unlike normal RegExp, allows inline comments (# //), partials (interpolated regex or string), and ignores insignificant whitespace. Flags are set at compile time. No dependencies.

npm install regx
INSTALL
IMPORT
SIG · REGX
R
regx
serializationjavascriptv1.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import regx from 'regx'
import { regx } from 'regx'
Default export only. Named import will yield undefined.
default
const regx = require('regx').default
const regx = require('regx')
CommonJS require returns a module with a default property; default export is not hoisted.
default
import regx from 'regx'; const rx = regx('gi'); const re = rx`/pattern/flags`;
const rx = regx('gi')('pattern');
regx() returns a tag function that must be used as a tagged template literal, not called as a function.

Shows creation of a tag function with flags, multiline regex with comments, and interop with a RegExp partial.

import regx from 'regx'; const rx = regx('i'); const pattern = rx` ^ // start of line [a-z]+ // one or more letters $ // end of line `; console.log(pattern); // /^[a-z]+$/i console.log(pattern.test('hello')); // true console.log(pattern.test('123')); // false // Using a partial const digit = /\d/; const mixed = rx` ${digit}+ // digits only `; console.log(mixed); // /\d+/i
Debug
Known issues
gotchaWhitespace at start/end of each line is stripped. To match literal spaces, use [ ].
fix
Use a character class like [ ] or \s to include whitespace.
affects: >=1.0.0 <=1.0.4
gotchaPartials (interpolations) must be valid RegExp or strings; strings require double escaping (e.g., '\\d' for \d).
fix
Pass /\d/ instead of '\d' to avoid escaping issues.
affects: >=1.0.0 <=1.0.4
deprecatedPackage has not been updated since 2016; no official deprecation but maintenance is absent.
fix
Consider alternatives like panda-regx or template-regexp for active maintenance.
affects: >=1.0.0
gotchaComments (//) only work if they are at the end of a line; inline // in the middle of a line may cause unexpected behavior.
fix
Place // only at the end of a line after the regex content.
affects: >=1.0.0 <=1.0.4
Errors
Common errors & fixes
import { regx } from 'regx' results in undefined
Named import used but package only exports default.
fix
Use default import: import regx from 'regx'
require('regx') returns an object with default undefined
CommonJS require accesses module.exports which has a default property.
fix
Use require('regx').default
regx('i')('/pattern/') is not a function
Calling tag function directly instead of using as tagged template literal.
fix
Use template literal: const rx = regx('i'); const re = rx`/pattern/`;
Unexpected whitespace in regex pattern
Whitespace at start/end of lines is automatically stripped.
fix
Use [ ] or \s to match literal whitespace characters.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
regx — npm install regx · libregistry