ISCL is a Intelligent Information Consulting System. Based on our knowledgebase, using AI tools such as CHATGPT, Customers could customize the information according to their needs, So as to achieve

Python Regular Expression Examples: the Colon

2
Definition:

>>> import re>>> x = '\nBeneath the wide and starry sky, \nDig the grave and let me lie, \nGlad did I live and gladly die, \nAnd I lay me down with a will:\n\nThis be the verse you grave for me: \nHere he lies where he longed to be, \nHome is the sailor, home from sea, \nAnd the hunter home from the hill.\n\n-- "Requiem" by Robert Louis Stevenson\n\n'>>> y = re.compile('l(?:ie)')>>> z = re.search(y,x)>>> print z.group()lie>>> u = 'Four score and seven years ago, our forefathers...'>>> y = re.compile('a(?:[rg])')>>> z = re.search(y,u)>>> print z.group()ar>>> y = re.compile('a(?:[rg]).*(?P<another>for(?:e))')>>> z = re.search(y,u)>>> print z.group()ars ago, our fore>>> print z.group(0)ars ago, our fore>>> print z.group(1)fore>>> print z.groups()('fore',)>>> print z.group('another')fore


Back to the main index of this glossary
Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.