
rovf
Veteran
Feb 2, 2012, 1:25 AM
Post #3 of 3
(27290 views)
|
Re: [OrcasKing] Using Regular Expression in Perl Programming
[In reply to]
|
Can't Post
|
|
Works for me:
$ perl -lwe 'qq(<Document ID="3" format="pdf">)=~ /^(.*?)<Document\s+ID="(\d+)"(.*?)>/s && print "found"' found In the example you posted, you had Windows-style double quotes, so I had to replace them to normal ASCII double quotes. Maybe that's the reason it did not work in your case. Of course, best would be - as it already had been pointed out - to not use a regexp to parse XML. There are several XML parsers available.
|