5
I have the text:
Regular expressions (often abbreviated to "regex") are a declarative language used for correspondence.
How do I get the content included in the parentheses?
I tried to:
$texto = "As expressões regulares (muitas vezes abreviado para "regex") são uma linguagem declarativa utilizada para correspondência." ;
preg_match("/\(*\)/", $texto, $testando);
var_dump($testando) ;
The exit is:
array (size=1)
0 => string ')' (length=1)
In the case of: $text = "Regular expressions (often abbreviated to 'regex') are a (declarative) language used for matching." Could bring the 2 sections between parentheses separately?
– Givanildo R. de Oliveira
@Taisbevalle, thank you! It worked fine. (often abbreviated to 'regex')
– HumbertoDONTEC
It remains to solve the problem cited by @Givanildor.deOliveira. When there are two sequences "654321(GGG) blá (HSH)123456" the return is "(GGG) BLÁ (HSH)" while the desirable would be "(GGG)" and "(HSH)"
– HumbertoDONTEC
@Givanildor.deOliveira edited the answer.
– rray
Fantastic @rray.
– Givanildo R. de Oliveira