Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

maximum count of replacements in python

s = 'one two one two one'
print(s.replace('one', 'XXX'))
# Output -
# XXX two XXX two XXX

s = 'one two one two one'
print(s.replace('one', 'XXX', 2))
# 2 is the number of count
# Output -
# XXX two XXX two one
Source by note.nkmk.me #
 
PREVIOUS NEXT
Tagged: #maximum #count #replacements #python
ADD COMMENT
Topic
Name
2+5 =