Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: s///g within m//g regions

by LanX (Saint)
on Nov 09, 2021 at 20:30 UTC ( [id://11138645]=note: print w/replies, xml ) Need Help??


in reply to Re^4: s///g within m//g regions
in thread s///g within m//g regions

TIMTOWTDI

use strict; use warnings; use Test::More; my $in = 'A |simple*example| is |so*simple| to come*up |with these*days| according to some *experts*'; my $exp = 'A |simple-example| is |so-simple| to come*up |with these-days| according to some *experts*'; my $start = qr/\|/; my $stop = qr/\|/; my $got; for ( split /($start|$stop)/s, $in) { if ( /$start/.../$stop/ ) { #print "<$_>"; s/\*/-/gs; } $got .= $_; } is($got,$exp); done_testing;

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^6: s///g within m//g regions
by LanX (Saint) on Nov 09, 2021 at 20:51 UTC
    > TIMTOWTDI

    use strict; use warnings; use Test::More; my $in = 'A |simple*example| is |so*simple| to come*up |with these*days| according to some *experts*'; my $exp = 'A |simple-example| is |so-simple| to come*up |with these-days| according to some *experts*'; my $start = qr/\|/; my $stop = qr/\|/; my $got = join "", map { /$start/.../$stop/ ? s/\*/-/gr : $_ } split /($start|$stop)/s, $in; is($got,$exp); done_testing;

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11138645]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-24 21:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found