Moteur RegExp NFA & Test en direct8 min de lectureMis à jour le
Maîtrise des expressions régulières : Moteur JavaScript RegExp et tests en direct
Testez vos expressions régulières instantanément, inspectez les groupes de capture et simulez des opérations de remplacement avec surbrillance dynamique.
W
Équipe d'ingénierie WEBioDD•100% Dans le navigateur & Zero-Trust
Points clés
- JavaScript utilise un moteur NFA (Automate Fini Non Déterministe) prenant en charge le backtracking et les lookarounds.
- Les groupes de capture extraient des sous-chaînes, tandis que les groupes non capturants regroupent sans allocation mémoire inutile.
- Les assertions lookahead et lookbehind valident le contexte environnant sans inclure les caractères dans le résultat.
- Les flags Regex (comme g, i, m) modifient fondamentalement le comportement de correspondance sur l'ensemble du document.
100% In-Browser & Local Execution
Tester et déboguer vos expressions régulières
Évaluez vos motifs Regex avec indexation des correspondances, tableau des groupes de capture et simulateur de remplacement.
- Real-time match highlighting
- Capture groups inspector
- Substitution simulator
- RegExp flags (g, i, m, s, u)
01.How the JavaScript RegExp Engine Works (NFA & Backtracking)
The JavaScript RegExp engine utilizes a Non-deterministic Finite Automaton (NFA). When matching a pattern against a string, the engine tests candidate paths. If a path fails, it backtracks to previous decision states. Understanding backtracking is crucial for avoiding Regular Expression Denial of Service (ReDoS) catastrophic backtracking vulnerabilities.
02.Mastering Capture Groups, Named Groups & Lookarounds
Capture groups allow you to isolate sub-patterns and reference them in string substitutions via $1, $2, etc. Named capture groups (?<name>...) assign semantic keys to matches. Lookahead assertions check if a pattern is followed by another pattern without including it in the match.
How to Test and Debug Regular Expressions
Step-by-step regex testing workflow.
1
Enter Regex Pattern
Type your regular expression into the pattern input field (e.g., [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}).
2
Select Regex Flags
Toggle flags like g (global), i (case-insensitive), or m (multiline).
3
Input Test String
Paste candidate text to view instant highlighted matches.
4
Inspect Capture Groups
Review the capture groups table to examine indexed and named sub-matches.
Frequently Asked Questions
Capturing groups ((...)) save the matched text for later extraction, while non-capturing groups ((?:...)) group expressions without saving memory.