如何正确使用js中的exec、test、match、search、replace、split方法?
- 内容介绍
- 文章标签
- 相关推荐
本文共计422个文字,预计阅读时间需要2分钟。
pythonimport re
def exec(string): result=re.findall(r'(\w+)', string) return [result[0], result[1]]
def test(string): return bool(re.search(r'\w+', string))
match(pa)
exec:对string进行正则处理,并返回匹配结果.array[0]为原字符串,array[i]为匹配在整个被搜索字符串中的位置。test:测试string是否包含有匹配结果,包含返回true,不包含返回false。
本文共计422个文字,预计阅读时间需要2分钟。
pythonimport re
def exec(string): result=re.findall(r'(\w+)', string) return [result[0], result[1]]
def test(string): return bool(re.search(r'\w+', string))
match(pa)
exec:对string进行正则处理,并返回匹配结果.array[0]为原字符串,array[i]为匹配在整个被搜索字符串中的位置。test:测试string是否包含有匹配结果,包含返回true,不包含返回false。

