Retrieve the match text (提取获取的字符)
2014-05-15 10:20
155 查看
需求:
获取字符串Do you like 12 or 34?中的12
方法:
1. Python
a. Global function
import re
match = re.search(r"\d+", subject)
if match:
result = match.group()
else:
result = ""
b. Compiled object
import re
reobj = re.compile(r"\d+")
match = reobj.search(subject)
if match:
result = match.group()
else:
result = ""
2. Tcl
regexp -linestop {\d+} $subject result
获取字符串Do you like 12 or 34?中的12
方法:
1. Python
a. Global function
import re
match = re.search(r"\d+", subject)
if match:
result = match.group()
else:
result = ""
b. Compiled object
import re
reobj = re.compile(r"\d+")
match = reobj.search(subject)
if match:
result = match.group()
else:
result = ""
2. Tcl
regexp -linestop {\d+} $subject result
相关文章推荐
- myeclipse下开发jface出现text包冲突[signer information does not match signer information of other classes in the same package]
- android EditText获取光标位置并插入字符删除字符
- Android EditText的输入监听,输入字符的动态获取
- 获取TextView控件字符长度
- AutoCompleteTextView不输入字符获取提示以及相关焦点问
- How to get the password text in a text with password property from another process using C++ - 用C++如何从不同进程获取密码框文本
- android EditText获取光标位置并安插字符删除字符
- android EditText获取光标位置并插入字符删除字符
- android EditText获取光标位置并安插字符删除字符
- android EditText获取光标位置并插入字符删除字符
- android EditText获取光标位置并插入删除字符与设置光标颜色
- Determine the Position and Length of the Match (获取匹配的起始位置,终止位置,和长度)
- Insert Part of the Regex Match into the Replacement Text (将正则匹配插入替换文本中)
- 怎么获取textview上触摸点的字符或者附近的字符?
- [转]How to retrieve the RPGLE source--如何从rpgle里面获取代码
- Android EditText的输入监听,输入字符的动态获取
- Insert the regex match into the replacement text (插入正则匹配到替换文本中)
- android EditText获取光标位置并插入字符删除字符
- Android EditText获取光标位置并插入字符删除字符
- Android EditText获取光标位置并插入字符删除字符