Hello everyone , I meet you again , I'm your friend, Quan Jun .
Example 1: Replace all... By default
s1 = '2019.10.30'
s2 = s1.replace('.', '-')
s2
'2019-10-30'
s1 # Does not affect the original string
'2019.10.30'
Example 2: Specify replacement quantity
s1 = '2019.10.30'
s2 = s1.replace('.', '-',1)
s2
'2019-10.30'
Example 3: Replace string
s1 = '2019.10.30'
s2 = s1.replace('19', '20')
s2
'2020.10.30'
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/133975.html Link to the original text :https://javaforall.cn