需求:
字符串中只有regex pattern
方法:
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!"
2. Tcl
set result [regexp -linestop {\Aregexp pattern\Z} $subject]
if {$result == 1} {
puts "Match Pass!"
} else {
puts "Match Fail!"
}