正規表示式

匹配、捕獲和替換文字

正在加載工具…

關於 正規表示式

匹配、捕獲和替換文字

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.

如何使用這個開發者工具

  1. Enter the expression, flags, and representative test text.
  2. Review full matches and capture groups, then add cases that should not match.
  3. 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.