{"library":"oniguruma-to-es","title":"Oniguruma to JavaScript RegExp Converter","description":"Oniguruma-To-ES is a JavaScript library designed to accurately translate Oniguruma regular expression patterns into equivalent native JavaScript RegExp objects. Currently at v4.3.5, the library maintains an active release cadence, frequently delivering bug fixes and feature enhancements. A key differentiator is its ability to support approximately 99.99% of Oniguruma regex features, making it a robust alternative to WASM-based Oniguruma implementations like `vscode-oniguruma`, offering a significantly smaller bundle size and often faster execution by leveraging native JavaScript regex engines. It deeply understands and compensates for the numerous syntactic and behavioral disparities between Oniguruma and JavaScript, including differences in flag support, group naming rules, and Unicode handling. The library is built upon `oniguruma-parser` and `Regex+`, ensuring battle-tested reliability from extensive use in TextMate grammars. Developers can also precompile regexes to further optimize bundle size and runtime performance, though the `EmulatedRegExp` class may still be required for advanced feature emulation.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install oniguruma-to-es"],"cli":null},"imports":["import { toRegExp } from 'oniguruma-to-es';","import { toRegExpDetails } from 'oniguruma-to-es';","import { EmulatedRegExp } from 'oniguruma-to-es';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { toRegExp } from 'oniguruma-to-es';\n\nconst onigurumaPattern = String.raw`(?x)\n  (?<n>\\d) (?<n>\\p{greek}) \\k<n>\n  ([0a-z&&\\h]){,2}\n`;\n\ntry {\n  const jsRegExp = toRegExp(onigurumaPattern, { target: 'ES2018' });\n  console.log('Converted RegExp:', jsRegExp.source);\n  console.log('Flags:', jsRegExp.flags);\n\n  // Example usage (note: the converted regex is /(?<n>\\p{Nd})(\\p{sc=Greek})(?>\\2|\\1)(?:[[0a-z]&&\\p{AHex}]){0,2}/v)\n  const testString = '1α1';\n  const match = testString.match(jsRegExp);\n  if (match) {\n    console.log('Match found:', match[0]);\n    console.log('Named capture group 'n':', match.groups?.n);\n  } else {\n    console.log('No match found.');\n  }\n\n} catch (error) {\n  console.error('Error converting regex:', error);\n}","lang":"typescript","description":"Demonstrates converting an Oniguruma pattern with 'x' flag, duplicate named capture groups, Unicode properties, and character class intersection into a native JavaScript RegExp, then tests it.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}