CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Regular Expression

 



hurz
Novice

Jul 17, 2014, 12:22 PM

Post #1 of 2 (3948 views)
Regular Expression Can't Post

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

Post #2 of 2 (3931 views)
Re: [hurz] Regular Expression [In reply to] Can't Post


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

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives