The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024

Latest message you have seen: RE: BT to RJ45 convertors


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: [OT] Perl Help using split



Quoting Paul Smith (ukha@xxxxxxx):

> I'm trying to automate file renaming and using perl.
>
> {Law & Order}{2005-05-26}{Identity}{10.00 PM Thu May 26,
> 2005}{SKYONE}.ty
>
> This is the example file name and thought I could use the
> split command, but can't work out the pattern match.
>
> What I'm looking for it to extract the information between the {} in
the
> file name.

Not the neatest way, but this works unless you have nested braces:

$s = '{Law & Order}{2005-05-26}{Identity}{10.00 PM Thu May
26,2005}{SKYONE}.ty';

$s =~ /^({.*?})({.*?})({.*?})({.*?})({.*?})/;

print "field1 = $1\n";
print "field2 = $2\n";
print "field3 = $3\n";
print "field4 = $4\n";
print "field5 = $5\n";

James



UKHA_D Main Index | UKHA_D Thread Index | UKHA_D Home | Archives Home

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.