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

Re: finding the last occurence of substring in string

by Ratazong (Monsignor)
on Jul 26, 2012 at 16:37 UTC ( #983870=note: print w/ replies, xml ) Need Help??


in reply to finding the last occurence of substring in string

Just for the sake of TIMTOWTDI (or fun, or for following Matthew 20:16), you may apply the following algorithm:

  • get the index of the reversed substring in the reversed string
  • calculate the position (lengthOfString minus index minus lengthOfSubstring)(with a possible off-by-one-correction)

Rata
  • Comment on Re: finding the last occurence of substring in string

Replies are listed 'Best First'.
Re^2: finding the last occurence of substring in string
by RichardK (Parson) on Jul 27, 2012 at 10:20 UTC

    if you want to get the reverse index why not just use rindex ? :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2016-07-01 00:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (405 votes). Check out past polls.