Tidak suka iklan? Pergi Bebas Iklan Hari ini

Konverter Rasa Regex (PCRE / JS / Python / Go)

Pengembang
IKLAN · MENGHAPUS?
MEMASUKKAN

Test Panel

Syntax Reference

IKLAN · MENGHAPUS?

Memandu

Regex Flavor Converter (PCRE / JS / Python / Go)

Regex Flavor Converter

Convert regular expressions between programming language flavors: PCRE (PHP), JavaScript, Python, Go, Java, and Ruby. Automatically converts named groups, flags, backreferences, and other syntax differences. Highlights incompatible features with clear warnings. Includes a test panel to validate your converted regex against sample strings.

Cara Penggunaan

Enter your regex pattern, select the source flavor (the language it’s written for) and the target flavor (the language you want to convert to). The converted regex appears instantly with any flags translated. Check the conversion notes for changes made and warnings about unsupported features. Use the test panel to validate the converted pattern against sample text.

Fitur

  • 6 Regex Flavors — PCRE (PHP), JavaScript (ES2018+), Python (re module), Go (regexp), Java (java.util.regex), and Ruby. Convert between any pair.
  • Named Group Conversion — Automatically converts between (?P<name>…) (PCRE/Python/Go) and (?<name>…) (JS/Java/Ruby) syntax.
  • Flag Translation — Converts flags between flavors: /gi (JS) ↔ re.IGNORECASE (Python) ↔ (?i) inline (PCRE/Go) ↔ Pattern.CASE_INSENSITIVE (Java).
  • Backreference Conversion — Named backreferences converted: (?P=name) ↔ \k<name> between flavors.
  • Incompatibility Warnings — Color-coded alerts: green for clean conversions, yellow for syntax changes, red for unsupported features (e.g., Go doesn’t support lookbehind, JS doesn’t support atomic groups).
  • Test Panel — Test the converted regex against sample strings. Shows matches, groups, and match count using JavaScript’s RegExp engine.
  • Syntax Reference — Collapsible reference table showing key differences between all flavors: named groups, lookahead/lookbehind, flags, character classes, atomic groups, Unicode support.
  • Auto-Convert — Results update instantly as you type or change flavors.

What Gets Converted

Named groups: (?P<name>) ↔ (?<name>) syntax differences.
Named backreferences: (?P=name) ↔ \k<name> ↔ \g{name}.
Flags: Inline (?imsx), suffix /gi, and language-specific constants.
Lookbehind assertions: Supported in PCRE/JS/Java, limited in Python/Ruby, unsupported in Go.
Atomic groups: (?>…) — PCRE/Java/Ruby only; warned for JS/Python/Go.
Possessive quantifiers: a++ — PCRE/Java/Ruby only.
Character classes: \R, \h, \v (PCRE-specific) flagged for other flavors.
Komentar: (?#…) syntax — PCRE/Python only.
Conditionals: (?(cond)yes|no) — PCRE only.

IKLAN · MENGHAPUS?

Why do regex flavors differ between languages?

Regular expression implementations evolved independently across programming languages. Perl’s regex engine (PCRE) became the most feature-rich, adding named groups, lookbehind, atomic groups, and other advanced features. Other languages adopted subsets: JavaScript initially had basic regex and gradually added features (named groups in ES2018, lookbehind in ES2018). Python’s re module uses (?P<name>) syntax inherited from an early proposal. Go deliberately chose a simpler regex engine (RE2) that guarantees linear-time matching but sacrifices features like lookbehind. Each language made different tradeoffs between power and performance.

What regex features can’t be converted?

Some features exist in only one or two flavors and have no equivalent in others. Lookbehind assertions don’t exist in Go’s RE2 engine — there’s no workaround, only a redesign of the pattern. Atomic groups and possessive quantifiers (PCRE/Java/Ruby) have no direct equivalent in JavaScript, Python, or Go. PCRE-specific character classes like \R (any line break), \h (horizontal whitespace), and \v (vertical whitespace) need to be expanded to character class equivalents. Conditional patterns (?(cond)yes|no) are PCRE-only. This tool warns you about these incompatibilities so you know what needs manual attention.

Is the test panel accurate for all flavors?

The test panel uses JavaScript’s native RegExp engine, so it accurately tests JavaScript regex behavior. For other target flavors, the test gives a reasonable approximation but may differ in edge cases — particularly around Unicode handling, line break behavior, and features that JavaScript doesn’t support (like atomic groups). For production use, always test your converted regex in the actual target language. The test panel is best used for quick validation of basic pattern matching.

What is the difference between PCRE and JavaScript regex?

PCRE (Perl Compatible Regular Expressions, used by PHP) is the most feature-rich flavor: it supports named groups with (?P<name>), variable-length lookbehind, atomic groups (?>…), possessive quantifiers (a++), conditional patterns, recursive patterns, and inline flag scoping (?i:…). JavaScript regex is simpler: named groups use (?<name>), lookbehind was added in ES2018, and there’s no support for atomic groups, possessive quantifiers, or conditionals. PCRE uses /pattern/flags syntax like JavaScript but supports more flags (x for verbose mode, s for DOTALL). Converting PCRE → JS often requires removing advanced features.

Ingin bebas iklan? Bebas Iklan Hari Ini

Instal Ekstensi Kami

Tambahkan alat IO ke browser favorit Anda untuk akses instan dan pencarian lebih cepat

Ke Ekstensi Chrome Ke Ekstensi Tepi Ke Ekstensi Firefox Ke Ekstensi Opera

Papan Skor Telah Tiba!

Papan Skor adalah cara yang menyenangkan untuk melacak permainan Anda, semua data disimpan di browser Anda. Lebih banyak fitur akan segera hadir!

IKLAN · MENGHAPUS?
IKLAN · MENGHAPUS?
IKLAN · MENGHAPUS?

Pojok Berita dengan Sorotan Teknologi

Terlibat

Bantu kami untuk terus menyediakan alat gratis yang berharga

Belikan aku kopi
IKLAN · MENGHAPUS?