流计算Alink

关注

python re.sub

流计算Alink

关注

阅读 70

2022-06-27

str1="2017-10-15 this is happy day..."
>>> re.sub("(\d{4})-(\d{2})-(\d{2})",r"\2/\3/\1",str1)
##'10/15/2017 this is happy day...'
>>> re.sub("(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})",r"\g<month>/\g<day>/\g<year>",str1)
#'10/15/2017 this is happy day...'

 


相关推荐

码农K

关于python 的re.sub用法

码农K 64 0 0

想溜了的蜗牛

Python:正则re.sub实现简易的模板引擎

想溜了的蜗牛 45 0 0

快乐小鱼儿_9911

re.sub(‘[^A-Za-z]+‘, ‘ ‘, line).strip().lower()

快乐小鱼儿_9911 43 0 0

cnlinkchina

20240907_091745 python 正则表达式 re.sub方法

cnlinkchina 8 0 0

boom莎卡拉卡

Windows系统上创建的txt文档名字不能包含特殊的字符 \ / : * ? " < > | ​ ​python替换操作(replace,re.sub)

boom莎卡拉卡 41 0 0

快乐码农Alan007

爬虫入门到精通_基础篇3(正则表达式基础_常用的匹配规则,re.match,re.search,re.findall,re.sub,re.compile)

快乐码农Alan007 15 0 0

想溜了的蜗牛

Python高频面试题——如何在字符串中删除指定字符,掌握strip()、replace()和re.sub ()正确使用方法!

想溜了的蜗牛 33 0 0

you的日常

python re(六)

you的日常 61 0 0

Fifi的天马行空

python re(二)

Fifi的天马行空 74 0 0

勇敢乌龟

python re模块

勇敢乌龟 55 0 0

精彩评论(0)

0 0 举报