i got a problem with ace.js. I need to select a word an then insert the word without the occurance of =. This is my code:
editor.$search.setOptions({needle: '[A-z,0-9,_,\-]*="[A-z,0-9,_,\-,.]*"', regExp:true});
ranges = editor.$search.findAll(editor.session);
randomRange = ranges[Math.floor(Math.random() * ranges.length)];
if (randomRange){
editor.selection.setRange(randomRange);
var content = editor.session.getTextRange(editor.getSelectionRange());
alert(content);
var result = content.replace('=', '');
alert(result);
editor.replace(result);
}
It selects a random occurance of that text. Then i replace the = with a space. But ace.js always replaces the text with the second occurance of the matched element, not with the first selected. Any suggestions? TY!
UPDATE: example:
<?xml version="1.0"?>
<PurchaseOrder PurchaseOrderNumber="99503" OrderDate="1999-10-20">
it selects version="1.0", deletes the =. then it´s version"1.0"
but now when i call the function editor.replace(result), it replaces PurchaseOrderNumber="99503" with that text so then its:
<?xml version="1.0"?>
<PurchaseOrder version"1.0" OrderDate="1999-10-20">
GOT IT! this should be the replace statement:
editor.session.replace(editor.selection.getRange(), result);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With