I can't make syntax highlighting make it work with RegEx


#1

I’m creating a package to find and rightlight certain words in a file.

I can get numbers and name, but I can not get it \xfff to work.

I can make Regex work as you can see in the follow link https://regex101.com/r/UNiOYw/1
But the text is not highlighted in the package.

high

This is my patterns:
‘patterns’: [
{
‘match’: ‘\b[0-9]+\b’
‘name’: ‘constant.numeric.pkmtrd’
},
{
‘match’: ‘\b\[x][f]+e\b’
‘name’: ‘support.other.pkmtrd’
}
]


#3

my patterns code in pastebin
https://pastebin.com/gZYzW4Vy


#4

You are using a string, so all backslashes must be escaped. For example, a literal backslash would be \\\\

Edit: It seems you have in the regex example, you just didn’t mark it as code properly in this forum.

Check the scope with Editor: Log cursor scope in the command palette. It most likely is working, but you haven’t assigned a colour to that scope.


#5

Hello, I solved the problem. As the text I would like to add a highlightning syntax was along with other characters then it was necessary to remove the “\b” from the begin and end of the regex.

{
  match: "\\[x][f]+e?"
  name: "constant.character.escape"
}

new

Thanx for the help!