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
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
  How to remove char from string?? ridgerunnersjw 2 155 Sep-30-2020, 03:49 PM
Last Post: ridgerunnersjw
  Including modules in Python using sys.path.append JoeDainton123 1 338 Aug-24-2020, 04:51 AM
Last Post: millpond
  Including a Variable In the HTML Tags When Sending An Email JoeDainton123 0 227 Aug-08-2020, 03:11 AM
Last Post: JoeDainton123
  SyntaxError: unexpected character after line continuation character siteshkumar 2 349 Jul-13-2020, 07:05 PM
Last Post: snippsat
  Remove escape characters / Unicode characters from string DreamingInsanity 5 951 May-15-2020, 01:37 PM
Last Post: snippsat
  how can i handle "expected a character " type error , when I input no character vivekagrey 2 586 Jan-05-2020, 11:50 AM
Last Post: vivekagrey
  Highlight and remove specific string of text itsalmade 5 722 Dec-11-2019, 11:58 PM
Last Post: micseydel
  How to get the index of a character from a string chihaya 1 499 Dec-03-2019, 12:54 PM
Last Post: buran
  "Up to but not including" (My personal guide on slicing & indexing) Drone4four 5 597 Nov-20-2019, 09:38 PM
Last Post: newbieAuggie2019
  Cannot Remove the Double Quotes on a Certain Word (String) Python BeautifulSoup soothsayerpg 5 2,281 Oct-27-2019, 09:53 AM
Last Post: newbieAuggie2019

Forum Jump:

User Panel Messages

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