跳到主要内容
Z

What is Regular expression?

A regular expression (regex) is a pattern that describes a set of strings, used to search, match, validate and replace text. Built from literal characters and special metacharacters (like . * + ? [ ] ( )), it is supported by virtually every programming language and text editor.

Regex combines literals with metacharacters: . matches any character, */+/? are quantifiers, [...] is a character class, ( ) groups, and ^/$ anchor to start/end. For example ^\d{3}-\d{4}$ matches a 7-digit phone number.

Regexes power form validation (emails, URLs), search-and-replace, log parsing and tokenizing — but complex patterns can be hard to read, so keep them documented.

Regular expression tools

常见问题

支持哪个版本的 XPath?

支持 XPath 1.0——浏览器原生支持的版本。XPath 2.0/3.0 的特性(正则表达式、序列、数据类型等)目前尚不支持。

为什么我的 HTML 查询没有返回任何结果?

HTML 模式会将你的代码包裹在 <code class="font-mono">html/body</code> 中,请相应地调整表达式(例如:<code class="font-mono">//body//div</code>)。

有哪些相关工具?

<a class="text-brand-600 hover:underline" href="/jsonpath-tester">JSONPath Tester</a> 用于查询 JSON;<a class="text-brand-600 hover:underline" href="/xml-formatter">XML Formatter</a> 可先对 XML 进行格式化清理。