Re: Need regex ^? help

[email protected] (ToddAndMargo via perl6-users)
Newsgroups perl.perl6.users
Message-ID <[email protected]>
On 4/29/24 17:42, ToddAndMargo via perl6-users wrote:
> Hi All,
> 
> I thought I understood ^ and ? used in a regex'es,
> but I don't.
> 
> ^ means from the beginning and ? from the end.
> 
> I am trying to put together an example
> of how to use them:
> 
> I have
> 
>     1.2.3.4
> 
> I want
>     1.2.3.0/24
> 
> So Far I have (not working):
> 
>     raku -e 'my $x="1.2.3.4"; $x~~s/ (.*) $(Q[.]) /$0Q[0/24]/; say $x;'
> 
> How do I do this with ^ and $  ?
> 
> Many thanks,
> -T


raku -e 'my $x="1.2.3.4"; $x~~s/ (.*) $(Q[.]) /$0$(Q[0.24])/; say $x;'
1.2.30.244
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.