Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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?
[robby_dobby]: Or India
LanX which means I can finally organize YAPC Asia in Sharm el Sheikh ;-)
[robby_dobby]: I attended a couple conferences (both in India). Left me with a renewed enthusiasm to do more, only to see it disappear in a few days!
[LanX]: Then come to YAPC EU in Amsterdam ...
[robby_dobby]: LanX: But that's in Africa! More like YAPC::Africa
choroba fears Amsterdam might fill him with enthusiasm to do nothing
[robby_dobby]: Uff, too expensive :-(
[LanX]: ... I found YAPC EU more entertaining (and international )than YAPC NA
[robby_dobby]: What's the site for YAPC::EU?
[LanX]: Robby Dobby no IIRC Sinai is already part of Asia

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2017-04-24 15:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (442 votes). Check out past polls.