def oneOf( strs, caseless=False, useRegex=True ):
if caseless:<EOL><INDENT>isequal = ( lambda a,b: a.upper() == b.upper() )<EOL>masks = ( lambda a,b: b.upper().startswith(a.upper()) )<EOL>parseElementClass = CaselessLiteral<EOL><DEDENT>else:<EOL><INDENT>isequal = ( lambda a,b: a == b )<EOL>masks = ( lambda a,b: b.startswith(a) )<EOL>parseElementClass = Literal<EOL><DEDENT>if isinstance(strs,(list,tuple)):<EOL><INDENT>symbols = list(strs[:])<EOL><DEDENT>elif isinstance(strs,basestring):<EOL><INDENT>symbols = strs.split()<EOL><DEDENT>else:<EOL><INDENT>warnings.warn("<STR_LIT>",<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL><DEDENT>i = <NUM_LIT:0><EOL>while i < len(symbols)-<NUM_LIT:1>:<EOL><INDENT>cur = symbols[i]<EOL>for j,other in enumerate(symbols[i+<NUM_LIT:1>:]):<EOL><INDENT>if ( isequal(other, cur) ):<EOL><INDENT>del symbols[i+j+<NUM_LIT:1>]<EOL>break<EOL><DEDENT>elif ( masks(cur, other) ):<EOL><INDENT>del symbols[i+j+<NUM_LIT:1>]<EOL>symbols.insert(i,other)<EOL>cur = other<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>i += <NUM_LIT:1><EOL><DEDENT><DEDENT>if not caseless and useRegex:<EOL><INDENT>try:<EOL><INDENT>if len(symbols)==len("<STR_LIT>".join(symbols)):<EOL><INDENT>return Regex( "<STR_LIT>" % "<STR_LIT>".join(_escapeRegexRangeChars(sym) for sym in symbols) )<EOL><DEDENT>else:<EOL><INDENT>return Regex( "<STR_LIT:|>".join(re.escape(sym) for sym in symbols) )<EOL><DEDENT><DEDENT>except:<EOL><INDENT>warnings.warn("<STR_LIT>",<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL><DEDENT><DEDENT>return MatchFirst( [ parseElementClass(sym) for sym in symbols ] )<EOL>
Helper to quickly define a set of alternative Literals, and makes sure to do
       longest-first testing when there is a conflict, regardless of the input order,
       but returns a C{L{MatchFirst}} for best performance.

       Parameters:
        - strs - a string of space-delimited literals, or a list of string literals
        - caseless - (default=False) - treat all literals as caseless
        - useRegex - (default=True) - as an optimization, will generate a Regex
          object; otherwise, will generate a C{MatchFirst} object (if C{caseless=True}, or
          if creating a C{Regex} raises an exception)