需求:@H_403_3@
字符串中只有regex pattern@H_403_3@
@H_403_3@
1. Python@H_403_3@
a. Global function@H_403_3@
import re@H_403_3@
if re.search("regex pattern\Z",subject):@H_403_3@
print "Match Pass!"@H_403_3@
else:@H_403_3@
print "Match Fail!"@H_403_3@
@H_403_3@
b. Compiled object@H_403_3@
import re@H_403_3@
reobj = re.compile("regex pattern\Z")@H_403_3@
if reobj.search(subject):@H_403_3@
print "Match Pass!"@H_403_3@
else:@H_403_3@
print "Match Fail!"@H_403_3@
@H_403_3@
2. Tcl@H_403_3@
set result [regexp -linestop {\Aregexp pattern\Z} $subject]
@H_403_3@
if {$result == 1} {@H_403_3@
puts "Match Pass!"@H_403_3@
} else {@H_403_3@
puts "Match Fail!"@H_403_3@
}@H_403_3@