Here’s a string that I may have:
(MyStringIsOneWholeWord *)
I have used the following javascript regular expression to get the text after the bracket if it starts with My.
/(^|\s|\()+My(\w+)/g,
The problem with this is that it includes the first bracket in the result, as that it is the letter/character that found it.
How would I get rid of the bracket in the result?
EDIT
For more information, I am editing the C Language javascript file of the SHJS syntax highlighter.
Here’s all the relevant code for this question:
[
/(^|\s|\()+My(\w+)/g,
'sh_keyword',
-1
]
If this was just JS you could use a capture group:
Then get the match at that group. However, it appears that SHJS will use the entire match, requiring the use of lookbehind, which is not supported by Javascript’s Regex engine.
To get around this, I’d suggest you to read the documentation. This part here:
Tells me that the resulting JS files aren’t meant to be edited. The docs say SHJS uses the same format as GNU Source-highlighting, which is specified here. So you should be editing the original
.lang(link) files and then converting them to.js.