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
  splitting a string with 2 different delimiters Skaperen 0 28 2 hours ago
Last Post: Skaperen
  get a string from a list if it is there Skaperen 5 150 Yesterday, 10:55 AM
Last Post: Larz60+
  I need to get only string datatype and report in excel file. akshay3210 3 128 Dec-12-2019, 09:53 AM
Last Post: akshay3210
  Reverse the string word sneha 2 182 Dec-12-2019, 03:37 AM
Last Post: sneha
  Highlight and remove specific string of text itsalmade 5 180 Dec-11-2019, 11:58 PM
Last Post: micseydel
  what happened to these string? Skaperen 2 94 Dec-11-2019, 02:28 AM
Last Post: ichabod801
  Select single letters from string based on separate string Jpen10 2 175 Dec-11-2019, 01:04 AM
Last Post: Jpen10
  Use String contents for checkbox name jcday 1 80 Dec-06-2019, 06:01 PM
Last Post: Larz60+
  How to get the index of a character from a string chihaya 1 90 Dec-03-2019, 12:54 PM
Last Post: buran
  Strange Characters in JSON returned string fioranosnake 4 140 Dec-02-2019, 07:25 PM
Last Post: fioranosnake

Forum Jump:


Users browsing this thread: 1 Guest(s)