in reply to Perl = reg Exp - Cut info in middle

Of course this could be done by regex:
my $yourstring="someinfo:Info_to_cut:Take_me_off"; $yourstring=~/^.*?:(.*?):.*$/; $info=$1;
I assumed that there are only two ':' in your string and you wanted the part between them.

Replies are listed 'Best First'.
Re^2: Perl = reg Exp - Cut info in middle
by ikegami (Patriarch) on Mar 23, 2006 at 16:35 UTC
    I think $yourstring=~/^[^:]*:([^:]*)/; might be faster, but only a Benchmark will tell for sure.
    A reply falls below the community's threshold of quality. You may see it by logging in.