Chaitanya Yanamadala <[email protected]> asked:
> i have a string like this
> <ComposedBlock ID="ZONE1-2" STYLEREFS="PAR1" HEIGHT="1062" WIDTH="1986"
> HPOS="573" VPOS="3003">
>
> i need to get the values between the " " after the ID= . So how can i
> do it, Can any one help me??
Assuming the string is on a single line:
#!/usr/bin/perl -w
use strict;
use warnings;
my $line = '<ComposedBlock ID="ZONE1-2" STYLEREFS="PAR1" HEIGHT="1062"
WIDTH="1986" HPOS="573" VPOS="3003">';
if( my( $id ) = ( $line =~ m/\s+ID="([^"]*)"/ ) ){
print "id value is '$id'\n";
} else {
print "no match found!\n";
}
__END__
Note that this method is fine for quickly grabbing a single value from a
string, but highly unsuitable for parsing a complex xml document.
HTH,
Thomas