New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Regular expressions #256
Comments
http://sourceforge.net/projects/tiny-rex looks good too. As a bonus it doesn't use functions called |
Haha, it's awesome, every time I think of something that would be great to have, but probably not worth opening an issue for (yet), you've already opened it yourself. |
There was no advance on that matter? |
It's possible, yes. It may happen - but not soon. I just haven't had time to work on it. For now the most annoying thing is sorting the lexer out (the grammar for it is nasty since '/' could be a divide, or the start of a regex) Espruino does have ES6 templated literals though, which are pretty much perfect for templating in a web service. Honestly, if you're trying to pull some framework in to Espruino you'll be disappointed anyway - it'll use up all your available memory before you've even had a chance to write any code! |
@gfwilliams Any movement on this? Finding myself needing RegEx the more things I do! |
Hi - not yet - the first step would be to make the Lexer distinguish regular expressions from other JS. I'd had a go at that, but it's not quite as easy as you'd hope because the slash is also used for divide. It's hard to find info on it but it looks like I can decide based on the previous token. What sort of things were you trying to do that needed regex? I think realistically even when it goes in, it might not be a full regex parser. |
You could add basic support via the Come to think of it, how are you parsing I think http://duktape.org/ has a built in parser so maybe you could check their source for ideas. Mostly I'd like to be able to do token replacement in a string (ideally doing this on a Stream as it is being piped from SD card to WiFi) |
Ok, I just added Regex parsing - it's nasty, but that's as good as it'll be by the look of it. No actual Regex implementation yet though, but at least (finally) it'll warn people when regex is used.
So basically that's just a repeated Even using RegEx isn't going to work as nicely as you expect though. For example assume (for the sake of not having a huge post) that
If you just regex on each block you're going to miss the Once you're doing all that, just using |
I was about to make a forum post about this but I thought I should just check GitHub first, glad I did. My usecase is removing multiple spaces from a string, e.g.
|
This is what I'm using in place for right now
|
Thanks - it's actually kind of annoying that there's no 'global replace' function. I seems that for most things, even just a barebones regexp function that allowed stuff like |
Leaving open, as we still have at minimum |
|
I may have found an issue with the regex implementation: |
Ahh, thanks! I just filed #1736 Looks like it's expecting something like |
This looks promising: https://github.com/cesanta/slre
Is GPLv2 compatible with the MPLv2 of Espruino though?
Boasts ~5kB compiled, which is probably as small as we could hope for.
It could do with some modification to use JsvStringIterator if it's going to be any use for long strings (which let's face it, it'll need to be good for);
The text was updated successfully, but these errors were encountered: