我需要使用以下格式在文档中搜索一些文本:
(#.#.#) ex; (1.4.6)
Run Code Online (Sandbox Code Playgroud)
尽管这很简单,但它超出了我的正则表达能力.
您可以使用以下正则表达式:
\(\d{1,2}\.\d{1,2}\.\d{1,2}\)
Run Code Online (Sandbox Code Playgroud)

示例PHP:
<?php
$str = "(1.12.12) some text (1.1.1) some other text (1.1232.1) text";
preg_match_all('/\(\d{1,2}\.\d{1,2}\.\d{1,2}\)/',$str,$matches);
print_r($matches);
?>
Run Code Online (Sandbox Code Playgroud)
输出:
Array
(
[0] => Array
(
[0] => (1.12.12)
[1] => (1.1.1)
)
)
Run Code Online (Sandbox Code Playgroud)
如果您想要可以有任意数字的位数(> 0),请使用以下正则表达式:
\(\d+\.\d+\.\d+\)
Run Code Online (Sandbox Code Playgroud)