capture items between [ ]
Posted: Fri Feb 09, 2007 2:35 pm
I am have the need to extract a string that in enclosed in [].
The data looks like so:
I need to extract the [WWonka] which in this case is the user name.
Here is what I have so far: I have been using ereg, just cause I don't know any better yet!
Below returns the users I want to see, but the second ereg does not contain any matches in $test.
I tried the folllowing as well but no dice!
The data looks like so:
Code: Select all
CN=Wonka\,Willy [WWonka],OU=test,OU=EastCoast,OU=People,DC=corp,DC=Wonka,DC=comHere is what I have so far: I have been using ereg, just cause I don't know any better yet!
Code: Select all
if (ereg('\[*\]',$info[$x]["member"][$i])){
echo "". $info[$x]["member"][$i]."<br>";
ereg('{[}\w*{]}]',$info[$x]["member"][$i],$test);
echo "<BR>";
print_r($test);
}I tried the folllowing as well but no dice!
Code: Select all
ereg('\[*\]',$info[$x]["member"][$i],$test);