#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2010 <NAME>.  All rights reserved.
#
"""Searching a substring of the input.
"""
#end_pymotw_header

import re

text = 'This is some text -- with punctuation.'
pattern = re.compile(r'\b\w*is\w*\b')

print 'Text:', text
print

pos = 0
while True:
    match = pattern.search(text, pos)
    if not match:
        break
    s = match.start()
    e = match.end()
    print '  %2d : %2d = "%s"' % \
        (s, e-1, text[s:e])
    # Move forward in text for the next search
    pos = e
    

#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2010 <NAME>.  All rights reserved.
#
"""Searching a substring of the input.
"""
#end_pymotw_header

import re

text = 'This is some text -- with punctuation.'
pattern = re.compile(r'\b\w*is\w*\b')

print 'Text:', text
print

pos = 0
while True:
    match = pattern.search(text, pos)
    if not match:
        break
    s = match.start()
    e = match.end()
    print '  %2d : %2d = "%s"' % \
        (s, e-1, text[s:e])
    # Move forward in text for the next search
    pos = e
    

#!/usr/bin/env python # encoding: utf-8 # # Copyright (c) 2010 <NAME>.  All rights reserved. # Searching a substring of the input. #end_pymotw_header # Move forward in text for the next search