M
mud_saisem
Hi There,
Could anybody please let me know how I would be able to extract the
words that have a = in the middle and print the whole word out. Also I
will never know how many : and in the word either.
eg: "This is a example item, order=TEST:ITEM:123 on shelf
shelf=1:4:23:f"
output: order=TEST:ITEM:123
shelf=1:4:23:f
This is what I have done so far but only prints out the word until the
first :
eg: order=TEST
#!/usr/bin/perl
system(clear);
$string = "This is a example item, order=TEST:ITEM:123 on shelf
shelf=1:4:23:f";
$str = $string;
print "String: $string\n\n";
sub extract
{
$x = shift;
print "Checking: $x\n";
return $x;
}
$string =~ s/(\w+=\w+)/extract $1/ge;
print "\n";
Could anybody please let me know how I would be able to extract the
words that have a = in the middle and print the whole word out. Also I
will never know how many : and in the word either.
eg: "This is a example item, order=TEST:ITEM:123 on shelf
shelf=1:4:23:f"
output: order=TEST:ITEM:123
shelf=1:4:23:f
This is what I have done so far but only prints out the word until the
first :
eg: order=TEST
#!/usr/bin/perl
system(clear);
$string = "This is a example item, order=TEST:ITEM:123 on shelf
shelf=1:4:23:f";
$str = $string;
print "String: $string\n\n";
sub extract
{
$x = shift;
print "Checking: $x\n";
return $x;
}
$string =~ s/(\w+=\w+)/extract $1/ge;
print "\n";