python string pattern code example

Example 1: pattern in python

rows = 6                        #Pattern(1,121,12321,1234321,123454321)
for i in range(1, rows + 1):
    for j in range(1, i - 1):
        print(j, end=" ")
    for j in range(i - 1, 0, -1):
        print(j, end=" ")
    print()

Example 2: re python3

import re
>>> m = re.search('(?<=abc)def', 'abcdef')
>>> m.group(0)
'def'

Example 3: regex in python

>>> import re
>>> p = re.compile('ab*')
>>> p
re.compile('ab*')

Example 4: python re

parse("Today is Dec 1 16", fuzzy_with_tokens=True)
 
parse("Today is Dec 1 14", fuzzy_with_tokens=True)
 
parse("Today is Nov 30 12", fuzzy_with_tokens=True)