鱼C论坛

 找回密码
 立即注册
查看: 1566|回复: 1

[已解决]正则表达式

[复制链接]
发表于 2017-11-8 21:54:35 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 likuo 于 2017-11-8 21:57 编辑
  1. >>> re.split('[\W]+', 'Words, words, words.')
  2. ['Words', 'words', 'words', '']
  3. >>> re.split('([\W]+)', 'Words, words, words.')
  4. ['Words', ', ', 'words', ', ', 'words', '.', '']
复制代码


这两个的区别在哪里?
最佳答案
2017-11-8 22:12:05
If capturing parentheses are used in pattern, then the text of all groups in the pattern are also returned as part of the resulting list.
如果在模式中使用捕获括号,则模式中所有分组的文本也作为结果列表的一部分返回。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2017-11-8 22:12:05 | 显示全部楼层    本楼为最佳答案   
If capturing parentheses are used in pattern, then the text of all groups in the pattern are also returned as part of the resulting list.
如果在模式中使用捕获括号,则模式中所有分组的文本也作为结果列表的一部分返回。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-3-3 20:24

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表