Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Shift regex search back 4 characters...

by ablanke (Prior)
on Mar 08, 2017 at 10:54 UTC ( #1183936=note: print w/replies, xml ) Need Help??


in reply to Shift regex search back 4 characters...

Hi,
maybe i'm simplifying your requirements too much or it's a matter of performance, but you could solve this by splitting the numbers.
#!/usr/bin/perl use strict; use warnings; my $numbers = '222,345,222,678,222,222,543,111,222'; my @numbers = split(',', $numbers); my $i = 1; for my $number (@numbers) { if ( '222' eq $number && $i < scalar(@numbers) ) { print "AFTER $number-$numbers[$i]\n"; } $i++; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2022-05-23 15:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?