I am trying to match the second string between quotes and while it works fine on node.js it fails on espruino v1.99.
With the resources available on espruino, how else would you do it?
>/\w+\.\w+/g.exec("form-data; name=\"file\"; filename=\"file.txt\"")
/\w+\.\w+/g.exec("form-data; name=\"file\"; filename=\"file.txt\"")
v2.01 is broken too.
Looks like there's a bug in how the index of the match is calculated - however if you make it a group then you can extract that group and you're sorted.
/(\w+\.\w+)/g.exec("form-data; name=\"file\"; filename=\"file.txt\"")
It's now fixed, so the latest builds will work better
I am not good at regular expressions. A better solution would be to look for the content between quotes after 'filename=' (to also get filenames without extension), but at least we spotted a small bug.
Ok, in that case I'd suggest:
/filename="([^"]+)"/g.exec("form-data; name=\"file\"; filename=\"file.txt\"")
Which matches filename="..." and returns what's inside the quotes
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem