Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string1 = "this is a test string : that behaves as I expectn"
- string2 = "this string does not behave as I expectn"
- field = CharsNotIn(":n")
- line = field + ZeroOrMore(Literal(":") + field) + LineEnd()
- print line.parseString(string1)
- print line.parseString(string2)
- ['this is a test string ', ':', ' that behaves as I expect', 'n']
- ['this string does not behave as I expect']
- string1 = "this is a test string : that behaves as I expect*"
- string2 = "this string also behaves as I expect*"
- field = CharsNotIn(":*")
- line = field + ZeroOrMore(Literal(":") + field) + Literal("*")
- print line.parseString(string1)
- print line.parseString(string2)
- ['this is a test string ', ':', ' that behaves as I expect', '*']
- ['this string also behaves as I expect', '*']
- >>> print line
- {!W:(:
- ) [{":" !W:(:
- )}]... LineEnd}
- >>> print line.parseString('xyzyy')
- ['xyzyy']
Add Comment
Please, Sign In to add comment