daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Jan 17th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string1 = "this is a test string : that behaves as I expectn"
  2. string2 = "this string does not behave as I expectn"
  3.  
  4. field = CharsNotIn(":n")
  5. line = field + ZeroOrMore(Literal(":") + field) + LineEnd()
  6.  
  7. print line.parseString(string1)
  8. print line.parseString(string2)
  9.    
  10. ['this is a test string ', ':', ' that behaves as I expect', 'n']
  11. ['this string does not behave as I expect']
  12.    
  13. string1 = "this is a test string : that behaves as I expect*"
  14. string2 = "this string also behaves as I expect*"
  15.  
  16. field = CharsNotIn(":*")
  17. line = field + ZeroOrMore(Literal(":") + field) + Literal("*")
  18.  
  19. print line.parseString(string1)
  20. print line.parseString(string2)
  21.    
  22. ['this is a test string ', ':', ' that behaves as I expect', '*']
  23. ['this string also behaves as I expect', '*']
  24.    
  25. >>> print line
  26. {!W:(:
  27. ) [{":" !W:(:
  28. )}]... LineEnd}
  29.    
  30. >>> print line.parseString('xyzyy')
  31. ['xyzyy']
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top