Given a dummy function as such:
#include "DigiKeyboard.h"
void setup() {
#start_shift_3
DigiKeyboard.sendKeyStroke(0);
#end_shift_3
}
void loop() {
DigiKeyboard.delay(2000);
}
I tried to get the content of the Setup function between the brackets and I tried
/[setup]+[(][a-zA-Z0-9=',]+[)][{]\n(.+?)\n+\s+[}]/gs
To get the result I want
#start_shift_3
DigiKeyboard.sendKeyStroke(0);
#end_shift_3
The problem is that the code was not written correctly because it works in the Regex site
But it doesn't work with javascript code and I think the reason is
regex single line flag /s
I searched a lot and read on Stackoverflow and the answers are not appropriate for the situation
So even though the code works there, it won't work with JavaScript
var string = `
#include "DigiKeyboard.h"
void setup(){
#start_shift_3
DigiKeyboard.sendKeyStroke(0);
#end_shift_3
}
void loop() {
DigiKeyboard.delay(2000);
}
`;
const regex = new RegExp("[setup]+[(][)][{]\n(.+?)\n+\s+[}]');
console.log(string.match(regex) == null);
}inside the function?