关于 正则表达式
匹配、捕获和替换文本
A pattern is easier to trust when its test set includes expected matches, near-misses, Unicode, line breaks, and empty input. The tester is most useful as a small reproducible case for a regex that will later live in application code.
如何使用这个开发者工具
- Enter the expression, flags, and representative test text.
- Review full matches and capture groups, then add cases that should not match.
- Try the replacement operation only after the match boundaries are correct, and keep the test examples with the expression.
隐私与数据处理
Regular-expression matching runs in the browser. Avoid pasting personal records or log files containing secrets; use short representative samples instead.
相关开发者工具
常见问题
Why does a flag change the result?
Flags can change case sensitivity, line boundaries, Unicode behavior, or whether matching continues after the first result. Test them deliberately.
Can a regex validate an entire document?
It can check a pattern, but a regex is not always the right parser for nested or structured formats such as JSON, XML, or programming languages.
What is a near-miss test?
It is an input that looks close to a valid match but should be rejected. Near-misses reveal missing boundaries and overly broad quantifiers.