How I can color the word in comment in specific color in codemirror?

I use my own mode to color some word in codemirror , I want to color the words inside the comment ("/* ggggg */") in green color , I did not how I can do it with codemirror , my try but not work :

CodeMirror.defineMode(“mymode”, function() {

return {
    token: function(stream,state) {

        if (stream.match("aaa") ) {
            return "style1";
        } else if (stream.match("bbb") ) {
            return "style2";
        } if ( stream.match("/*") ||stream.match("*/") ) {
            //prevToken = null;
            //stream.eatSpace();
            return null;
        }
        else {
            stream.next();
            return null;
        }
    }
};

});

this my try online : my try but not work

What I want : I want when type any word between ("/* */") to color the words in green like the comment in (Visual studio , Netbeans …)

any help ?

thanks solved

@kernal - How?

@kernal
Can you share your solution please ?

@Haemma @soutn

I’m not sure how they did it, but here is how I did it…

You can do something like this :

var comment = $(this).find('.cm-comment');
for (var i = 0; i < comment.length; i++) {
	if (comment.eq(i).text().startsWith('//')) {
		comment.eq(i).addClass('inline-comment');
	}
}

Find all comments inside the ‘.CodeMirror’ object.

Loop through each and if it starts with two forward slashes (an inline comment) add the class 'inline-comment' to that span.

Now you need to have a style for comments, followed by inline-comment like so:

.cm-comment {
    color: red;
}
.inline-comment {
    color: green;
}

Hello,

In my case I want to colorize exactely the words/strings which are matching this:

function tokenBase(stream, state) {
   var regexRS = /RS\_\w*/g;
   var matchRS = regexRS.exec(string);
   if (matchRS1 !== null) {
      return ret("ruleset", "ruleset");
   }

}

Unfortunately it’s just colorizing the whole line.

@Souleste - Can you support?

Thank you very much.