[ubuntu-uk] [OT] Quick Perl question...

Matthew Bassett hewbass at gmail.com
Tue Jul 13 07:47:46 BST 2010


I'm pretty sure you need to avoid matching the start of the 2nd tag, otherwise text of the form:

<solar>abcde</solar><solar>fghij</solar>

Will be extracted as:

abcde</solar><solar>fghij

E.g. Use a character class that avoids matching the start of a tag:

$solar_info =~ s!<solar>([^<]*)</solar>!$1!g;

--
Matthew Bassett <hewbass at gmail.com>
Sorry about the top posting- am replying from my phone.


-----Original Message-----
From: Matt Wheeler
Sent:  12/07/2010 23:46:32
Subject:  Re: [ubuntu-uk] [OT] Quick Perl question...

[some pruned text]

You could remove both the start and end tags with something like

$solar_info =~ s!<solar>(.*)</solar>!$1!;

(note I'm also using ! instead of / so I don't have to escape the /)

-- 
Matt Wheeler
m at funkyHat.org

-- 
ubuntu-uk at lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-uk
https://wiki.ubuntu.com/UKTeam/




More information about the ubuntu-uk mailing list