Retrieve a list of all matches (提取所有匹配的列表)
来源:互联网 发布:c语言游戏编程 编辑:程序博客网 时间:2024/04/20 06:03
需求:
获取字符串Do you like 12 or 34?中的12, 34
方法:
1. Python
a. Global function
import re
subject = "Do you like 12 or 34?"
result = re.findall(r"\d+", subject)
b. Compiled object
import re
reobj = re.compile(r"\d+")
result = reobj.findall(subject)2. Tcl
set subject "Do you like 12 or 34?"
set result ""
set pos 0
while {[regexp -indices -start $pos -linestop {\d+} $subject offsets]==1} {
set pos [expr {1+[lindex $offsets 1]}]
lappend result [string range $subject [lindex $offsets 0] [lindex $offsets 1]]
}
0 0
- Retrieve a list of all matches (提取所有匹配的列表)
- Replace All Matches Between the Matches of Another (替换所有在匹配间的匹配)
- Replace all Matches (替换所有匹配)
- Replace All Matches Within the Matches of Another Regex (替换匹配中的匹配)
- list all files of a pc
- 1.20OpenCV-- a list of all modules
- How to list all tags of a docker image
- Replace Matches Reusing Parts of the Match (替换重新使用部分匹配的匹配)
- 输出一个集合所有子集的元素和(Print sums of all subsets of a given set)
- 获取peergroup的所有peers(Getting a list of the peers in a PeerGroup)
- All of a Sudden
- List All Of The Subsets
- List of all MySQL commands
- List of All Excel Constants
- Get a list of all application currently installed on a phone
- A function to retrieve the directory of a program
- 收藏项目备忘列表- a list for all stars project on github
- [CrackCode] 4.4 Creates a linked list of all the nodes at each depth of a given tree
- CORBA通过IOR文件远程获取实现类
- 如何创造财富?硅谷创业之父 Paul Graham 《黑客与画家》思维导图
- MyEclipse8.6注册码亲测可用
- 死锁
- 为什么phpmyadmin数据库中只能插入数字,不能插入中英文
- Retrieve a list of all matches (提取所有匹配的列表)
- 请放下你的无效社交
- Python面向对象编程-封装
- iOS: autosizing
- 值得研究的J2EE开源项目推荐
- Oracle手工生成段建议(Segment Advisor)
- Row Cache Objects
- hdu4351 线段树 区间合并
- 关于MapKit的简单用法