Example string
$Data=":2-Name1:4-Name2:3-Name3:1-Name4:";
I need to get the following info
:4-Name2:
But All I can search with is
:4-anything:
In other words I know it starts with :4-
then it has a name in the middle
and ends with the next :
my guess is
$Info = ($Data =~ /(:4-*:)/);
$Info if the var assigned the value sought.
$Data is the string I am searching
:4- and the last : are know
* are the unknown characters, if any
here is the program
#!/usr/bin/perl
use strict ;
my $Data=":2-Name1:4-Name2:3-Name3:1-Name4:";
my $Info = ($Data =~ /(:4-*:)/);
print ">$Info<";