#!/usr/bin/perl use strict; use warnings; my $string = " * [[Test789][Test123]]"; my $val = ($string =~ /\[([^\]]+)/g)[1]; print $val;