convert_pattern
Translate regular expressions between Python and JavaScript syntax, flagging unsupported features and validating the converted pattern in the target engine.
Instructions
Translate a regex between Python and JavaScript syntax, with explicit warnings.
Handles named groups and named backreferences, \A \Z and $ (using exact lookaround equivalents), inline global flags, verbose mode, {,n}, \U and \u{...} escapes, [^] and [], and the g/y/u flags. Things with no equivalent (atomic groups, possessive quantifiers, \p{..} in Python re, POSIX classes, recursion) are left unchanged and listed as WARNINGS. Differences that cannot be fixed syntactically (Unicode-aware \d \w vs ASCII-only) are listed too. The result is compiled in the target engine to prove it is at least valid; run test_regex or compare_engines to prove it is equivalent.
from_engine / to_engine: "python", "javascript" (or "js"), "regex". flags: flags of the source pattern; the converted flags are returned.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| flags | No | ||
| pattern | Yes | ||
| timeout_s | No | ||
| to_engine | Yes | ||
| from_engine | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |