I am using the react ace editor. I have created a custom highlight rule as is documented elsewhere. The code is here:
export class CustomHighlightRules extends window.ace.acequire("ace/mode/text_highlight_rules").TextHighlightRules {
constructor() {
super();
this.$rules = {
start: [
{
token: "keyword",
regex: "def"
}
]
};
}
}
The problem is that when I type something like def somedeftext into the editor, the word "def" in the very middle of "somedeftext" is highlighted incorrectly. What causes this behavior?
I found that changing the regex as follows works:
regex: "\\bdef\\b"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.