Peter Otten <__pete...@web.de> writes: > >>> pattern = re.compile("(\d+)$") > >>> match = pattern.search( "LINE: 235 : Primary Shelf Number (attempt 1): 1") > >>> match.group() > '1'
An alternative way to accomplish the above using the ‘match’ method:: >>> import re >>> pattern = re.compile("^.*:(? *)(\d+)$") >>> match = pattern.match("LINE: 235 : Primary Shelf Number (attempt 1): 1") >>> match.groups() ('1',) > See <https://docs.python.org/dev/library/re.html#search-vs-match> Right. Always refer to the API documentation for the API you're attempting to use. -- \ “Without cultural sanction, most or all of our religious | `\ beliefs and rituals would fall into the domain of mental | _o__) disturbance.” —John F. Schumaker | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list