-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestpyparsing.py
33 lines (19 loc) · 1.02 KB
/
testpyparsing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
from pyparsing import *
testString = "[List: Liste des tAches]"
listTitle = Suppress("[")+Word(alphas)+Suppress(":")+Group(OneOrMore(Word(alphas+alphas8bit)))+Suppress("]")
# listTitle = Suppress("[")+Word(alphas)+Suppress(":")+Group(OneOrMore(Regex(r"(.+)")))+Suppress("]")
title = listTitle.parseString(testString)
print title
# print alphas
# lineBody = SkipTo(lineEnd).setParseAction(mustBeNonBlank)
# # now define a line with a trailing lineEnd, to be replaced with a space character
# textLine = lineBody + Suppress(lineEnd).setParseAction(replaceWith(" "))
# # define a paragraph, with a separating lineEnd, to be replaced with a double newline
# para = OneOrMore(textLine) + Suppress(lineEnd).setParseAction(replaceWith("\n"))
# print para.parseString(test)v bd
# greet = Word( alphas ) + "," + Word( alphas ) + "!"
# element = Word( caps, lowers )
# integer = Word( digits )
# elementRef = Group( element + Optional( integer, default="1" ) )
# chemicalFormula = OneOrMore( elementRef )