python里使用正则表达式的连接符
来源:互联网 发布:男淘宝头像图片大全 编辑:程序博客网 时间:2024/06/04 19:04
在前面的例子里,我们学习使用集合里字符或非集合里的字符,这时都是要把每个字符写出来的,但是有时需要把26个小写字母都放到集合里,那么按集合的方法,得输入26次,一个一个键入去,这样比较花时间,也容易出错,那么有没有更好的方法呢?这个是有的,就是使用正则表达式的连接符的功能:-,比如表示26个小写字符,就使用[a-z]就可以了。例子如下:
结果输出如下:
'[a-z]+' (sequences of lowercase letters)
'This is some text -- with punctuation.'
.'his'
.....'is'
........'some'
.............'text'
.....................'with'
..........................'punctuation'
'[A-Z]+' (sequences of uppercase letters)
'This is some text -- with punctuation.'
'T'
'[a-zA-Z]+' (sequences of letters of either case)
'This is some text -- with punctuation.'
'This'
.....'is'
........'some'
.............'text'
.....................'with'
..........................'punctuation'
'[A-Z][a-z]+' (one uppercase followed by lowercase)
'This is some text -- with punctuation.'
深入浅出Numpy
五子棋游戏开发
http://edu.csdn.net/course/detail/5487
#python 3.6#蔡军生 #http://blog.csdn.net/caimouse/article/details/51749579#from re_test_patterns import test_patternstest_patterns( 'This is some text -- with punctuation.', [('[a-z]+', 'sequences of lowercase letters'), ('[A-Z]+', 'sequences of uppercase letters'), ('[a-zA-Z]+', 'sequences of letters of either case'), ('[A-Z][a-z]+', 'one uppercase followed by lowercase')],)
结果输出如下:
'[a-z]+' (sequences of lowercase letters)
'This is some text -- with punctuation.'
.'his'
.....'is'
........'some'
.............'text'
.....................'with'
..........................'punctuation'
'[A-Z]+' (sequences of uppercase letters)
'This is some text -- with punctuation.'
'T'
'[a-zA-Z]+' (sequences of letters of either case)
'This is some text -- with punctuation.'
'This'
.....'is'
........'some'
.............'text'
.....................'with'
..........................'punctuation'
'[A-Z][a-z]+' (one uppercase followed by lowercase)
'This is some text -- with punctuation.'
'This'
深入浅出Numpy
http://edu.csdn.net/course/detail/6149
Python游戏开发入门
http://edu.csdn.net/course/detail/5690
你也能动手修改C编译器
http://edu.csdn.net/course/detail/5582
纸牌游戏开发
http://edu.csdn.net/course/detail/5538
五子棋游戏开发
http://edu.csdn.net/course/detail/5487
RPG游戏从入门到精通
http://edu.csdn.net/course/detail/5246
WiX安装工具的使用
http://edu.csdn.net/course/detail/5207
俄罗斯方块游戏开发
http://edu.csdn.net/course/detail/5110
boost库入门基础
http://edu.csdn.net/course/detail/5029
Arduino入门基础
http://edu.csdn.net/course/detail/4931
Unity5.x游戏基础入门
http://edu.csdn.net/course/detail/4810
TensorFlow API攻略
http://edu.csdn.net/course/detail/4495
TensorFlow入门基本教程
http://edu.csdn.net/course/detail/4369
C++标准模板库从入门到精通
http://edu.csdn.net/course/detail/3324
跟老菜鸟学C++
http://edu.csdn.net/course/detail/2901
跟老菜鸟学python
http://edu.csdn.net/course/detail/2592
在VC2015里学会使用tinyxml库
http://edu.csdn.net/course/detail/2590
在Windows下SVN的版本管理与实战
http://edu.csdn.net/course/detail/2579
Visual Studio 2015开发C++程序的基本使用
http://edu.csdn.net/course/detail/2570
在VC2015里使用protobuf协议
http://edu.csdn.net/course/detail/2582
在VC2015里学会使用MySQL数据库
http://edu.csdn.net/course/detail/2672
阅读全文
0 0
- python里使用正则表达式的连接符
- python里使用正则表达式的边界符进行匹配
- python里使用正则表达式
- python里使用正则表达式的转义字符的匹配
- python里使用正则表达式的重复模式
- python里使用正则表达式的非贪婪模式
- python里使用正则表达式的集合字符
- python里使用正则表达式的句号和星号
- python里使用正则表达式的预先定义集合字符
- python里使用正则表达式的限制边界功能
- python里使用正则表达式的全匹配功能
- python里使用正则表达式的词组匹配功能
- python里使用正则表达式的分组命名方式
- python里使用正则表达式的组嵌套
- python里使用正则表达式的嵌套可选模式
- python里使用正则表达式的非捕获模式
- python里使用正则表达式的选项参数
- python里使用正则表达式的MULTILINE标志
- 动态树(一)
- 系统工具
- 无人零售场景、技术全解读:伪需求or真风口?【附下载】| 智东西内参
- 简明Github Pages与Hexo教程
- c/c++ 字符转换为数字
- python里使用正则表达式的连接符
- MyBatis学习总结(二)——使用MyBatis对表执行CRUD操作
- Lesson 2:作业4:编写代码模拟手机与SIM卡的组合关系。
- mac 安全 没有允许任何来源
- 总结c语言操作符
- tarjan板子(割点割边连通分量)
- 对原生态jdbc程序中的问题总结
- JAVA数值四舍五入
- [NLP]如何进行情感分析