How is regex (1.2.3)?
2 answers
You can use the following regex:
\(\d{1,2}\.\d{1,2}\.\d{1,2}\)
PHP example:
<?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 to have any number of digits (> 0) use the following regex:
\(\d+\.\d+\.\d+\)
+7
source to share
Have you tried this?
$int = preg_match("/\(\d{1,2}\.\d{1,2}\.\d{1,2}\)/", "(11.2.33)", $matches);
You can test it here http://micmap.org/php-by-example/en/function/preg_match
+1
source to share