vladimarius/pyap

How to Change Street number and street name in regex's rules

Opened this issue · 0 comments

Hi Dear vladimarius

Thank you for publishing this program I wanna use your program for euro country that has different street addresses formating
for example :
AUSTRIA
"""Mr J Brownhall
264 High Street
ALLAMBIE NSW 2100
AUSTRALIA"""

has this formating you implemented in US code in this format :
full_street = r"""
(?:
(?P<full_street>
{street_number}?,?\ ?
{street_name}?,?\ ?

        (?:[\ \,]{street_type})\,?\ ?
        {post_direction}?\,?\ ?
        {floor}?\,?\ ?
        {building}?\,?\ ?
        {occupancy}?\,?\ ?
        {po_box}?
    )
)""".format(street_name=street_name,
            street_number=street_number,
            street_type=street_type,
            post_direction=post_direction,
            floor=floor,
            building=building,
            occupancy=occupancy,
            po_box=po_box,
            )

I get in trouble when I want to change the street number and street name :
full_street = r"""
(?:
(?P<full_street>
{street_name}?,?\ ?
{street_number}
(?:[\ ,]{street_type}),?\ ?
{post_direction}?,?\ ?
{floor}?,?\ ?
{building}?,?\ ?
{occupancy}?,?\ ?
{po_box}?
)
)""".format(street_name=street_name,
street_number=street_number,
street_type=street_type,
post_direction=post_direction,
floor=floor,
building=building,
occupancy=occupancy,
po_box=po_box,
)

and error is :
raise source.error(msg, len(condname) + 1)
re.error: unknown group name 'street_number' at position 142 (line 8, column 28)

Could you possibly help me
I would be grateful