Bottom Page

Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to find previous string of a string

I am struggling at problem which is how to find previous string in a string.

For example i have a string
A= "my name is prince"

Now i want to find "prince" when prince found return "my name is"

How can i do that?
You like this post
Explore string slicing. See what the below gives you (the literal string can be replaced by a variable).

"Mary had a little lamb"[:10]

So, you can find where the string you are looking for starts, and then slice the string to return everything before that.
You like this post
I am trying to help you, really, even if it doesn't always seem that way

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Highlight and remove specific string of text itsalmade 5 156 1 hour ago
Last Post: micseydel
  what happened to these string? Skaperen 2 79 Yesterday, 02:28 AM
Last Post: ichabod801
  Select single letters from string based on separate string Jpen10 2 109 Yesterday, 01:04 AM
Last Post: Jpen10
  Reverse the string word sneha 1 75 Dec-10-2019, 05:00 PM
Last Post: stullis
  Use String contents for checkbox name jcday 1 77 Dec-06-2019, 06:01 PM
Last Post: Larz60+
  How to get the index of a character from a string chihaya 1 88 Dec-03-2019, 12:54 PM
Last Post: buran
  Strange Characters in JSON returned string fioranosnake 4 131 Dec-02-2019, 07:25 PM
Last Post: fioranosnake
  type of object as a string Skaperen 1 80 Dec-02-2019, 08:01 AM
Last Post: midarq
  Python C API - Issue with string as arugments JRHeisey 2 133 Nov-30-2019, 04:53 AM
Last Post: casevh
  Error in the code ->ValueError: could not convert string to float: ' ' eagleboom 1 206 Nov-29-2019, 06:19 AM
Last Post: ThomasL

Forum Jump:

Users browsing this thread: 1 Guest(s)