Python Forum
function t split a string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
function t split a string
#1
i just wrote a function to split a string into parts based on a list of delimiters used in sequence.

>>> splits('abcdefghijklm',['b','ef','ij'])
['a','cd','gh','klm']
i wrote this because i needed it in a big script i was making. did i waste my time doing this?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
re.split
Reply
#3
what i wrote uses a list of (usually different) delimiters, each doing a split only once. and the delimiters are raw, so the code that creates them does not need to translate them to regular expressions.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  passing a string to a function to be a f-string Skaperen 3 3,988 Nov-06-2020, 06:14 AM
Last Post: Gribouillis
  a function to look for dates in a string Skaperen 6 3,953 May-09-2020, 11:03 PM
Last Post: Skaperen
  f-string capability in a function Skaperen 8 5,706 Dec-26-2019, 03:19 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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