ure - regular expressions api

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
User avatar
cagiva
Posts: 22
Joined: Wed Dec 14, 2016 4:49 pm

ure - regular expressions api

Post by cagiva » Sun Oct 29, 2017 1:29 am

Why doesn't ure have the ure.sub() or match.groupdict() functions? Is there a workaround for that in the MicroPython?

User avatar
cagiva
Posts: 22
Joined: Wed Dec 14, 2016 4:49 pm

Re: ure - regular expressions api

Post by cagiva » Mon Oct 30, 2017 7:41 am

I was able to make it work without sub() and groupdict(). However, I cannot figure out why this generates ValueError: Error in regex, but it run perfectly fine with standard Python re api.

Code: Select all

import ure
ure.compile('^{}$'.format('/cam/(?P<epoch>.+)'))

SpotlightKid
Posts: 380
Joined: Wed Apr 08, 2015 5:19 am

Re: ure - regular expressions api

Post by SpotlightKid » Mon Oct 30, 2017 7:17 pm

From the documentation:
Counted repetitions ({m,n}), more advanced assertions, named groups, etc. are not supported.
(My emphasis)

User avatar
pythoncoder
Posts: 3420
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: ure - regular expressions api

Post by pythoncoder » Tue Oct 31, 2017 5:23 am

@cagiva I suggest you read https://github.com/micropython/micropyt ... ifferences for some insight into the MicroPython micro libraries.
Peter Hinch

User avatar
cagiva
Posts: 22
Joined: Wed Dec 14, 2016 4:49 pm

Re: ure - regular expressions api

Post by cagiva » Tue Oct 31, 2017 6:13 am

Hi Peter,

I'm well aware that MicroPython does not support the entire python standard library. However, it will be great if the core team can consider extending the basic grouping syntax to add named-groups. It's a very helpful feature for parsing dynamic URIs/URLs containing named gapturing groups. In particular for those running with the ESP8266 boards.

This would be a change to extmod/modure.c and it should not make its implementation that much heavier for the small platforms.

Post Reply