替换Python中第一次出现的字符串
发布于 2021-01-29 19:35:04
我有一些示例字符串。如何用空字符串替换长字符串中第一次出现的该字符串?
regex = re.compile('text')
match = regex.match(url)
if match:
url = url.replace(regex, '')
关注者
0
被浏览
72