in reply to extracting a substring from a string - multiple variables
Using the fubarred xml from your question in the CB:
use warnings; use strict; my $string = q {...blah...<file fiop="foo" length="304507"/> SyncBookm +arkRecordType12345·bjbjUU</file>...blah}; my $foo = qr {<file fiop="([a-z]+)" length="(\d+)"/> (.+)(?=</file>)}; if ($string =~ m#$foo#) { print "\nMatched \"fiop\" label: |$1|\nMatched Length: |$2|\nMatche +d data: |$3|\n"; } else { print "no match \n"; } print "\nDone \n\n";
OUTPUT
Matched "fiop" label: |foo|
Matched Length: |304507|
Matched data: |SyncBookmarkRecordType12345?+bjbjU?U?|
Done
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: extracting a substring from a string - multiple variables
by walinsky (Scribe) on Oct 28, 2007 at 13:02 UTC |