lundi 17 octobre 2016

PHP regex pattern to extract string like [3,4,aAn]

With this peace of code i want to extract value like [3,6,AN] from a string.

$custom='[4,100,A]@erric.com';

 $regexIpAddress = '/\[\d{1,3}\,\d{1,3}\,[a|A|Aa|aA|aN|Na|AN|NA|ANa||AaN|NAa|NaA|aAN|aNA]\]/';        

 preg_match($regexIpAddress, $custom, $match);

var_dump($match);
$return = random($match[0]);

var_dump($return);

I want to extract with the predefined regex pattern the value like [2,4,A] , [2,4,Aa], [20,5,AaN]

The regex pattern that i've used extract only tag like [2,4,A] or [2,4,a] Please check if there any solution to extract all possible value.

Many Thanks.

Aucun commentaire:

Enregistrer un commentaire