| Version 5 (modified by , 16 years ago) ( diff ) |
|---|
PyParsing
pyparsing providers a simple way of creating parsers for logical text patterns.
It is included in Sahan Eden's modules folder.
A simple tutorial for pyparsing could be found at : http://www.rexx.com/~dkuhlman/python_201/python_201.html#SECTION007600000000000000000
Documentation for pyparsing is located at : http://crpppc19.epfl.ch/doc/python-pyparsing/HowToUsePyparsing.html
Example usage is shown below.
from pyparsing import delimitedList, Word, alphanums ,ParseException, Group
from pyparsing import Suppress, nums
resource = delimitedList(Word(alphanums+"_"), '/')
phone = Word(nums) # doesnot accept country code yet
address = (Suppress("eden.")+resource) | phone | Word(alphanums+"_ . + @ ")
addresses = delimitedList(Group(address))
string = "eden.pr_person/1/asd,eden.la/1/1,9935648569"
add = addresses.parseString(string)
print add
------------
==> Result
[['pr_person', '1', 'asd'], ['la', '1', '1'], ['9935648569']]
Note:
See TracWiki
for help on using the wiki.

