Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

substring a string in the reverse direction  RSS feed

 
JayaSiji Gopal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a string 1099647.

I need to substring this string from 7 to 4. Can this be done?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no single method call to do it, but you can just write a loop to append characters to a StringBuilder.
 
Jeff Storey
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also do it as follows:



You may have to tweak your indices of 4 and 7 if this is not exactly what you want, but this should give you the idea.

Jeff
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!