【python】给正则匹配部分命名
2024-10-11 16:31:57
可以用?P<name>的方法给正则匹配的部分命名。
例:要将<字母,数字>的部分命名为test
x = "abc <haha,123> test @@"
pattern = "(?P<test>\<\w+,\d+\>)"
m = re.search(pattern, x)
r = m.group("test")
print r
输出:
<haha,123>
最新文章
- Pairwise Sum and Divide 51nod
- spring mvc <;mvc:annotation-driven/>; 自定义拦截器不走
- 即时反应的input和propertychange方法
- ie6-ie8中不支持opacity透明度的解决方法
- 提供RESTful服务
- tomcat域名访问配置
- HDU 4417 - Super Mario ( 划分树+二分 / 树状数组+离线处理+离散化)
- 一个简单的flask程序
- 《微信小程序七日谈》- 第五天:你可能要在登录功能上花费大力气
- html中p标签行间距的问题
- Winform 中 dataGridView 导出到Excel中的方法总结
- Confluence 6 修改日志文件的大小数量和级别
- 案例学python——案例一:抓图
- ubuntu下的网速限制软件wondershaper (2011-09-18 00:00:00)转载▼
- https://stackoverflow.com/questions/40949967/running-storm-from-intellij-nimbus-error
- iOS之Block总结以及内存管理
- JavaScript:正则表达式 应用
- Linux进程地址空间和虚拟内存
- 我对于C#的想法
- oracle 查看表空间以及剩余量