Re: regex observation & question regarding re:escape()

new topic     » goto parent     » topic index » view thread      » older message » newer message
jessedavis said...

Windows 7 pro sp1 euphoria: 4.0.5 (362497032f33, 2012-10-11)

I guess I am missing something here. I don't see what it is.

... Regular expressions are hairy enough without all the extra backslashes.
In any event, the docs should agree with the performance!

regards, jd

Sorry, can't help with "normal" regex. But I agree that it can be quite tricky. I also agree that \std is not always up to scratch. What I did in my own work was write a custom simplified regex parser/matcher and changed the escape char to be a forward slash. In my system your expr would then look like this:

sequence p1 = re:Parse( "Payroll_is_ /$ /*/*/* 15.00") 

Which is fine if the programmer is the one entering the regex [and can remember how it is supposed to go]. Hmmm, that expr doesn't look like it'd do much. Is this just an example to show the issue or is it, in fact, typical? I might be wrong but it looks to me as if you'd almost be better off doing a straight text match:

integer try = match( "Payroll is $***15.00", s) 

But if you were looking for payroll totals then..

sequence p1 = re:Parse( "Payroll_is_ /$ [*]{0,4} /d+ . /d{2}") -- Alas, non-standard regex.. 

Spock

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu