Name

match()

Examples
s = "Inside a tag, you will find <tag>content</tag>."
m = match(s, "<tag>(.*?)</tag>")
print("Found '%s' inside the tag" % m[1])
# Prints to the console:
# "Found 'content' inside the tag."
s1 = "Have you ever heard of a thing called fluoridation. "
s1 += "Fluoridation of water?"
s2 = "Uh? Yes, I-I have heard of that, Jack, yes. Yes."
m1 = match(s1, "fluoridation")
if m1 != None:  # If not none, then a match was found
    # This will print to the console, since a match was found.
    print("Found a match in '" + s1 + "'")
else:
    print("No match found in '" + s1 + "'")
m2 = match(s2, "fluoridation")
if m2 != None:
    print("Found a match in '" + s2 + "'")
else:
    # This will print to the console, since no match was found.
    print("No match found in '" + s2 + "'")
Description
Syntax
match(str, regexp)
Parameters
str
regexp
Related matchAll()
.split()
.join()
Updated on Wed Jan 18 17:32:21 2017.
Creative Commons License