{"id":26184,"library":"regx","title":"regx","description":"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.","status":"maintenance","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/shannonmoeller/regx","tags":["javascript","compiler","expression","regex","regexp","regular","rx","string","tag"],"install":[{"cmd":"npm install regx","lang":"bash","label":"npm"},{"cmd":"yarn add regx","lang":"bash","label":"yarn"},{"cmd":"pnpm add regx","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export only. Named import will yield undefined.","wrong":"import { regx } from 'regx'","symbol":"default","correct":"import regx from 'regx'"},{"note":"CommonJS require returns a module with a default property; default export is not hoisted.","wrong":"const regx = require('regx')","symbol":"default","correct":"const regx = require('regx').default"},{"note":"regx() returns a tag function that must be used as a tagged template literal, not called as a function.","wrong":"const rx = regx('gi')('pattern');","symbol":"default","correct":"import regx from 'regx'; const rx = regx('gi'); const re = rx`/pattern/flags`;"}],"quickstart":{"code":"import regx from 'regx';\n\nconst rx = regx('i');\nconst pattern = rx`\n  ^        // start of line\n  [a-z]+   // one or more letters\n  $        // end of line\n`;\n\nconsole.log(pattern); // /^[a-z]+$/i\nconsole.log(pattern.test('hello')); // true\nconsole.log(pattern.test('123')); // false\n\n// Using a partial\nconst digit = /\\d/;\nconst mixed = rx`\n  ${digit}+  // digits only\n`;\nconsole.log(mixed); // /\\d+/i\n","lang":"javascript","description":"Shows creation of a tag function with flags, multiline regex with comments, and interop with a RegExp partial."},"warnings":[{"fix":"Use a character class like [ ] or \\s to include whitespace.","message":"Whitespace at start/end of each line is stripped. To match literal spaces, use [ ].","severity":"gotcha","affected_versions":">=1.0.0 <=1.0.4"},{"fix":"Pass /\\d/ instead of '\\d' to avoid escaping issues.","message":"Partials (interpolations) must be valid RegExp or strings; strings require double escaping (e.g., '\\\\d' for \\d).","severity":"gotcha","affected_versions":">=1.0.0 <=1.0.4"},{"fix":"Consider alternatives like panda-regx or template-regexp for active maintenance.","message":"Package has not been updated since 2016; no official deprecation but maintenance is absent.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Place // only at the end of a line after the regex content.","message":"Comments (//) only work if they are at the end of a line; inline // in the middle of a line may cause unexpected behavior.","severity":"gotcha","affected_versions":">=1.0.0 <=1.0.4"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use default import: import regx from 'regx'","cause":"Named import used but package only exports default.","error":"import { regx } from 'regx' results in undefined"},{"fix":"Use require('regx').default","cause":"CommonJS require accesses module.exports which has a default property.","error":"require('regx') returns an object with default undefined"},{"fix":"Use template literal: const rx = regx('i'); const re = rx`/pattern/`;","cause":"Calling tag function directly instead of using as tagged template literal.","error":"regx('i')('/pattern/') is not a function"},{"fix":"Use [ ] or \\s to match literal whitespace characters.","cause":"Whitespace at start/end of lines is automatically stripped.","error":"Unexpected whitespace in regex pattern"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}