def scanString( self, instring, maxMatches=_MAX_INT, overlap=False ):
if not self.streamlined:<EOL><INDENT>self.streamline()<EOL><DEDENT>for e in self.ignoreExprs:<EOL><INDENT>e.streamline()<EOL><DEDENT>if not self.keepTabs:<EOL><INDENT>instring = _ustr(instring).expandtabs()<EOL><DEDENT>instrlen = len(instring)<EOL>loc = <NUM_LIT:0><EOL>preparseFn = self.preParse<EOL>parseFn = self._parse<EOL>ParserElement.resetCache()<EOL>matches = <NUM_LIT:0><EOL>try:<EOL><INDENT>while loc <= instrlen and matches < maxMatches:<EOL><INDENT>try:<EOL><INDENT>preloc = preparseFn( instring, loc )<EOL>nextLoc,tokens = parseFn( instring, preloc, callPreParse=False )<EOL><DEDENT>except ParseException:<EOL><INDENT>loc = preloc+<NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>if nextLoc > loc:<EOL><INDENT>matches += <NUM_LIT:1><EOL>yield tokens, preloc, nextLoc<EOL>if overlap:<EOL><INDENT>nextloc = preparseFn( instring, loc )<EOL>if nextloc > loc:<EOL><INDENT>loc = nextLoc<EOL><DEDENT>else:<EOL><INDENT>loc += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>loc = nextLoc<EOL><DEDENT><DEDENT>else:<EOL><INDENT>loc = preloc+<NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT><DEDENT>except ParseBaseException as exc:<EOL><INDENT>if ParserElement.verbose_stacktrace:<EOL><INDENT>raise<EOL><DEDENT>else:<EOL><INDENT>raise exc<EOL><DEDENT><DEDENT>
Scan the input string for expression matches.  Each match will return the
matching tokens, start location, and end location.  May be called with optional
``maxMatches`` argument, to clip scanning after 'n' matches are found.  If
``overlap`` is specified, then overlapping matches will be reported.

Note that the start and end locations are reported relative to the string
being parsed.  See :class:`parseString` for more information on parsing
strings with embedded tabs.

Example::

    source = "sldjf123lsdjjkf345sldkjf879lkjsfd987"
    print(source)
    for tokens,start,end in Word(alphas).scanString(source):
        print(' '*start + '^'*(end-start))
        print(' '*start + tokens[0])

prints::

    sldjf123lsdjjkf345sldkjf879lkjsfd987
    ^^^^^
    sldjf
            ^^^^^^^
            lsdjjkf
                      ^^^^^^
                      sldkjf
                               ^^^^^^
                               lkjsfd