Re: How to cut up a long line

[email protected] (William Michels via perl6-users)
Newsgroups perl.perl6.users
Message-ID <[email protected]>
Hi Todd,

~$ raku -ne 'put $/.join("\n") if m:g/ <?before  download> .*? <?before \> | \h+ > /;'  todd_test.txt
download='betterbird-128.6.0esr-bb20.de.linux-x86_64.tar.bz2'
download='betterbird-128.6.0esr-bb20.en-US.linux-x86_64.tar.bz2'
download='betterbird-128.6.0esr-bb20.es-AR.linux-x86_64.tar.bz2'

See: https://docs.raku.org/syntax/%24%2F
See: https://docs.raku.org/language/regexes#Lookahead_assertions

OR:

~$ raku -ne 'put $/.join("\n") if m:g/ <( download  .*? )> [ \> | \h+ ] /;'  todd_test.txt
download='betterbird-128.6.0esr-bb20.de.linux-x86_64.tar.bz2'
download='betterbird-128.6.0esr-bb20.en-US.linux-x86_64.tar.bz2'
download='betterbird-128.6.0esr-bb20.es-AR.linux-x86_64.tar.bz2'

See: https://docs.raku.org/language/regexes#Capture_markers:_%3C(_)%3E

Let me know if this is part of a larger script, how you're obtaining the input line(s), etc., if you need more guidance.

HTH, 

Bill.


> On Jan 10, 2025, at 17:50, ToddAndMargo via perl6-users <[email protected]> wrote:
> 
> Hi All,
> 
> I am scratching my head trying to figure out how to cut
> up this long line;
> 
> 
> download='betterbird-128.6.0esr-bb20.de.linux-x86_64.tar.bz2'>	<div class="img bz2"></div>	<div class="name">		<div class="file fs-1-2 bold">betterbird-128.6.0esr-bb20.de.linux-x86_64.tar.bz2</div>		<div class="data upper size fs-0-7"><span class="bold">Size:</span> 80.26<span class="fs-0-8 bold">MB</span></div>		<div class="data upper modified fs-0-7"><span class="bold">Last modified:</span> Tue. January 7th, 2025 - 10:54pm</div>	</div></a></div><div class="block"><a href="LinuxArchive/betterbird-128.6.0esr-bb20.en-US.linux-x86_64.tar.bz2" class="bz2" download='betterbird-128.6.0esr-bb20.en-US.linux-x86_64.tar.bz2'>	<div class="img bz2"></div>	<div class="name">		<div class="file fs-1-2 bold">betterbird-128.6.0esr-bb20.en-US.linux-x86_64.tar.bz2</div>		<div class="data upper size fs-0-7"><span class="bold">Size:</span> 80.04<span class="fs-0-8 bold">MB</span></div>		<div class="data upper modified fs-0-7"><span class="bold">Last modified:</span> Tue. January 7th, 2025 - 10:42pm</div>	</div>	</a></div><div class="block"><a href="LinuxArchive/betterbird-128.6.0esr-bb20.es-AR.linux-x86_64.tar.bz2" class="bz2" download='betterbird-128.6.0esr-bb20.es-AR.linux-x86_64.tar.bz2'>	<div class="img bz2"></div>	<div class="name">		<div class="file fs-1-2 bold">betterbird-128.6.0esr-bb20.es-AR.linux-x86_64.tar.bz2</div>	
> 
> 
> What I want to come out of it is an array of stings starting
> at "download" and ending at ">" or "<"
> 
> download='betterbird-128.6.0esr-bb20.de.linux-x86_64.tar.bz2'
> download='betterbird-128.6.0esr-bb20.en-US.linux-x86_64.tar.bz2'
> download='betterbird-128.6.0esr-bb20.es-AR.linux-x86_64.tar.bz2'x86_64.tar.bz2
> 
> 
> Many thanks,
> -T
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.