Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: index using a range

by rnewsham (Chaplain)
on Jun 13, 2013 at 23:06 UTC ( #1038856=note: print w/replies, xml ) Need Help??


in reply to index using a range

A slight variation on the solution proposed by vsespb, I think this is a little closer to what you want.

my $Str1 = "000001"; my $Index = length($1) if $Str1 =~ /^(0*)[1-9]$/; print "$Index\n";

Replies are listed 'Best First'.
Re^2: index using a range
by romano (Initiate) on Jun 17, 2013 at 15:19 UTC
    I was hoping I could incorporate the range ([0-9] or ^0) directly into the ‘index’ statement.
    $Index – index($Str1, ‘the first non-zero value’);
    but I guess not. So, it needs to be done in 2 statements.

    thanks,

    romano (aka KennB)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1038856]
help
Chatterbox?
[erix]: and my solfège is a little rusty too
[stonecolddevin]: damn where's a working cblast? looks like several of them are out of commission
[erix]: Tanktalus home node has one
[stonecolddevin]: erix thanks mate
[stonecolddevin]: also lol @ "I stomped a crap"
[stonecolddevin]: Disciplus i was just amazed he's returned after the thorough stomp that BrowserUk and several other monks gave him for spreading crap info
[stonecolddevin]: i will admit i find the responses to his threads incredibly entertaining

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2017-06-22 20:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (529 votes). Check out past polls.