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
  First Byte of a string is missing while receiving data over TCP Socket shahrukh1987 2 63 5 hours ago
Last Post: DeaD_EyE
  line number of first and second occurance of string in a file mdalireza 1 58 Yesterday, 09:55 AM
Last Post: perfringo
  Split a long string into other strings with no delimiters/characters krewlaz 4 89 Nov-15-2019, 02:48 PM
Last Post: ichabod801
  input string split Eric7Giants 3 90 Nov-13-2019, 07:19 PM
Last Post: Gribouillis
  Delete minimum occurence in a string RavCOder 10 241 Nov-12-2019, 01:08 PM
Last Post: RavCOder
  getting first letters of a string Unknown_Relic 1 80 Nov-12-2019, 11:16 AM
Last Post: perfringo
  Print string in a single line RavCOder 8 170 Nov-08-2019, 09:45 AM
Last Post: perfringo
  Get partial string from os.system() zinho 1 67 Nov-06-2019, 11:20 AM
Last Post: zinho
  Make color for string when print to console hadoan 6 195 Oct-31-2019, 01:40 PM
Last Post: hadoan
  How can i judge 1st string position is correct number christing 3 150 Oct-30-2019, 03:32 AM
Last Post: newbieAuggie2019

Forum Jump:

Users browsing this thread: 1 Guest(s)