Page 1 of 1
ure - regular expressions api
Posted: Sun Oct 29, 2017 1:29 am
by cagiva
Why doesn't ure have the ure.sub() or match.groupdict() functions? Is there a workaround for that in the MicroPython?
Re: ure - regular expressions api
Posted: Mon Oct 30, 2017 7:41 am
by cagiva
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>.+)'))
Re: ure - regular expressions api
Posted: Mon Oct 30, 2017 7:17 pm
by SpotlightKid
From the
documentation:
Counted repetitions ({m,n}), more advanced assertions, named groups, etc. are not supported.
(My emphasis)
Re: ure - regular expressions api
Posted: Tue Oct 31, 2017 5:23 am
by pythoncoder
@cagiva I suggest you read
https://github.com/micropython/micropyt ... ifferences for some insight into the MicroPython micro libraries.
Re: ure - regular expressions api
Posted: Tue Oct 31, 2017 6:13 am
by cagiva
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.