I'm trying to get a value between brackets at caret position. For this i use the regex https://regex101.com/r/7BqGEy/1 with the following method.
editor.getModel().findNextMatch(/\[\%(.*?)%]/gs, editor.getPosition(), true, false, null, true)
But i don't know why the regex give me null value. Am i doing it right, then how can i work with the regex. Or did you have an other method to get the value ?
EDIT:
I have tried this solution but this isn't working
var editor = monaco.editor.create(document.getElementById('container'), {
value: "dzqdqzdqz [%function()%] dzdzqdqzd",
language: 'javascript'
});
var myBinding = editor.addCommand(monaco.KeyCode.F9, function () {
const match1 = editor.getModel().findNextMatch('%', editor.getPosition(), false, false, null, true);
const match2 = editor.getModel().findNextMatch(/\[\%(.*?)%]/gs, editor.getPosition(), true, false, null, true);
const match3 = editor.getModel().findNextMatch(/\[\%(.*?)%]/g, editor.getPosition(), true, false, null, true);
console.log('match1',match1)
console.log('match2',match2)
console.log('match3',match3)
alert('F9 pressed!');
});
Sorry for my bad English :/
