需求:
字符串中只有regex pattern
方法:
@H_403_14@1. Python
a. Global function
import re
if re.search("regex pattern\Z",subject):
print "Match Pass!"
else:
print "Match Fail!"
b. Compiled object
import re
reobj = re.compile("regex pattern\Z")
if reobj.search(subject):
print "Match Pass!"
else:
print "Match Fail!"
@H_403_14@2. Tcl
set result [regexp -linestop {\Aregexp pattern\Z} $subject]
if {$result == 1} {
puts "Match Pass!"
} else {
puts "Match Fail!"
}
原文链接:https://www.f2er.com/regex/361757.html