Home: Perl Programming Help: Regular Expressions:
Regular Expression



hurz
Novice

Jul 17, 2014, 12:22 PM


Views: 13139
Regular Expression

Is there a way to find the last name (here: Name3) of the following XML Tag?

1. "One-Two-Three" is a variable string separated with minus-sign
2. /Name1/Name2/Name3 is a variable path and can have any path length and any path names separated with slash


Code
<TAG DEST="One-Two-Three">/Name1/Name2/Name3</TAG>



BillKSmith
Veteran

Jul 18, 2014, 4:57 AM


Views: 13122
Re: [hurz] Regular Expression


Code
use strict; 
use warnings;
my $string = '<TAG DEST="One-Two-Three">/Name1/Name2/Name3</TAG>';

my ($name) = $string =~ m/[\/]([^\/]+)<\/TAG>$/;

print $name, "\n";

Good Luck,
Bill