Toggle navigation
English
Chinese
Python Sandbox
Please refer to
this tutorial
to find more details on the following codes.
# # This code finds lines starting with A and ending with B. # In includes two examples - one matching the pattern and one # not matching the pattern. # import re ########################### # Example 1 ########################### print("Example 1") line = "A BIG BUG GOT INSIDE MY LAB" match = re.search( '^A.*B$', line) if match: print("match.group() : ", match.group()) else: print("No match!") ########################### # Example 2 ########################### print("Example 2") line = "TWO BIG BUGS GOT INSIDE MY LAB" match = re.search( '^A.*B$', line) if match: print("match.group() : ", match.group()) else: print("No match!")
Run
List