Bottom Page

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

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
Quote
#2
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
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  regex match in a string batchen 4 242 Yesterday, 08:48 AM
Last Post: batchen
  Converting query string as a condition for filter data. shah_entrance 1 63 Jan-14-2020, 09:22 AM
Last Post: perfringo
  How to print the 2nd column of a searched string in a csv ptey07 2 103 Jan-11-2020, 11:25 AM
Last Post: ptey07
  I want to filter out words with one letter in a string (pig latin translator) po0te 1 99 Jan-08-2020, 08:02 AM
Last Post: perfringo
  Print string after decode martinzeifang 1 136 Jan-02-2020, 10:16 AM
Last Post: buran
  Replacing characters in a string with a list cjms981 1 143 Dec-30-2019, 10:50 PM
Last Post: micseydel
  splitting a string with 2 different delimiters Skaperen 4 250 Dec-30-2019, 04:49 AM
Last Post: BamBi25
  string literals in a list. Not what I expected. tycarac 3 158 Dec-28-2019, 05:31 AM
Last Post: tycarac
  How to check if user entered string or integer or float?? prateek3 5 3,481 Dec-21-2019, 06:24 PM
Last Post: DreamingInsanity
  how to convert list to string after append !! evilcode1 3 158 Dec-16-2019, 09:50 AM
Last Post: buran

Forum Jump:


Users browsing this thread: 1 Guest(s)