I need to search documents for a bit of text with this format:
(#.#.#) ex; (1.4.6)
As simple as this may appear, it is outside my regex skills.
You can use the following regex:
\(\d{1,2}\.\d{1,2}\.\d{1,2}\)
DEMO
Sample 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);
?>
Output:
Array
(
[0] => Array
(
[0] => (1.12.12)
[1] => (1.1.1)
)
)
If you want can have any number of digits (>0) , use following regex:
\(\d+\.\d+\.\d+\)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With