As a side note, NetWallah's solution calls perl from the command line -- if you wanted to use it in your code, do this:
while ($desc =~ /\[(.*?)\]/g)
{
}
$org = $1 or '';
or
$desc =~ s/\[(.*?)\]//g;
$org = $1 or '';
The regex used essentially matches all data within brackets, but only saves the last one. The first example uses m//, and must therefore be run through a loop as the /g modifier merely saves the place where the previous regex match ended.
The second option will destroy the string stored in $desc, but does not require the loop.
|