Toggle navigation
English
Chinese
Python Sandbox
Please refer to
this tutorial
to find more details on the following codes.
########################### # Example 1 ########################### import re print("Example 1") line = "A BIG BUG GOT INSIDE MY LAB" match = re.search( 'G\s(B\SG)\s(G\S\S)', line) if match: print("match.group() : ", match.group()) print("match.group(1) : ", match.group(1)) print("match.group(2) : ", match.group(2)) else: print("No match!") print("Example 2") match = re.search( 'G\s(B(\S)G)\sG', line) if match: print("match.group() : ", match.group()) print("match.group(1) : ", match.group(1)) print("match.group(2) : ", match.group(2)) else: print("No match!")
Run
List