Regular Expressions don't work - ure

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
zitt
Posts: 6
Joined: Thu Mar 25, 2021 11:40 pm

Regular Expressions don't work - ure

Post by zitt » Wed Apr 07, 2021 5:15 am

As a fairly experienced python scripter; I've hit a new issue which seems to indicate the UEFI port of micropython has bug in Regular expressions.

I'm using an out-of-date version of micropython compiled for UEFI (https://github.com/tianocore/tianocore. ... k-for-UEFI) v1.12 but cannot get regular expressions to function correctly. I've spent quite a bit of time trying to figure out why; but I'm just not familar enough with the micropython code to figure out why.

This simple example aways results in no match:

Code: Select all

import ure as re

fsre = re.compile('^([Ff][Ss]\d+\:){0,1}([\\|\/]{0,1}.*)$', re.DEBUG)
path = 'FS0:\\'
match = fsre.match(path)
if match:
    print("match: ",end='')
    print(match.groups())
else:
    print('no match: %s\n' % path)  
The purpose of the code above is to splitdrive() the filesystem from a given path so we can interpret uefi file systems. As I stated I always get the message:
no match: FS0:\

I haven't tried the example yet under the linux port; but honestly, I expect it to work because it's such a simple example.

Anyone have suggestions on how to go about debugging this on UEFI or in general?

zitt
Posts: 6
Joined: Thu Mar 25, 2021 11:40 pm

Re: Regular Expressions don't work - ure

Post by zitt » Wed Apr 07, 2021 5:23 am

I stand corrected; my simple example in the linux port also fails. Output as follows:

Code: Select all

/mnt/v/micro.python$ micropython tstRe.py
 0: rsplit 5 (3)
 2: any
 3: jmp 0 (-5)
 5: save 0
 7: assert bol
 8: save 2
10: class 2 0x46-0x46 0x66-0x66
16: class 2 0x53-0x53 0x73-0x73
22: namedclass d
24: rsplit 22 (-4)
26: char :
28: save 3
30: char {
32: char 0
34: char ,
36: char 1
38: char }
40: save 4
42: class 2 0x7c-0x7c 0x2f-0x2f
48: char {
50: char 0
52: char ,
54: char 1
56: char }
58: split 63 (3)
60: any
61: jmp 58 (-5)
63: save 5
65: assert eol
66: save 1
68: match
Bytes: 69, insts: 31
no match: FS0:\

Post Reply