Python Forum
Remove from end of string up to and including some character
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove from end of string up to and including some character
#3
change url_find('.') to url_rfind('.') will give you what you want
Output:
>>> url = 'wikipedia.com' >>> print(url[:url.rfind('.')]) wikipedia >>> url = 'en.wikipedia.com' >>> print(url[:url.rfind('.')]) en.wikipedia
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Messages In This Thread
RE: Remove from end of string up to and including some character - by menator01 - May-17-2020, 09:24 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  remove gilberishs from a "string" kucingkembar 2 269 Mar-15-2024, 08:51 AM
Last Post: kucingkembar
  Function to count words in a list up to and including Sam Oldman45 15 6,597 Sep-08-2023, 01:10 PM
Last Post: Pedroski55
Smile please help me remove error for string.strip() jamie_01 3 1,203 Oct-14-2022, 07:48 AM
Last Post: Pedroski55
  Writing string to file results in one character per line RB76SFJPsJJDu3bMnwYM 4 1,383 Sep-27-2022, 01:38 PM
Last Post: buran
  Remove a space between a string and variable in print sie 5 1,786 Jul-27-2022, 02:36 PM
Last Post: deanhystad
  How do I remove spurious "." from a string? Zuhan 7 2,051 Apr-12-2022, 02:06 PM
Last Post: Pedroski55
  Including data files in a package ChrisOfBristol 4 2,552 Oct-27-2021, 04:14 PM
Last Post: ChrisOfBristol
  Not including a constructor __init__ in the class definition... bytecrunch 3 11,905 Sep-02-2021, 04:40 AM
Last Post: deanhystad
  Regex: a string does not starts and ends with the same character Melcu54 5 2,429 Jul-04-2021, 07:51 PM
Last Post: Melcu54
  [solved] unexpected character after line continuation character paul18fr 4 3,414 Jun-22-2021, 03:22 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020