I'm using Prism.js which is syntax highlighter, and it highlights the word matching certain regex.
I want to match any word after the word git
, so I tried to use positive lookbehind like this.
(?<=git )\w+
Unfortunately, it seems that positive lookbehind is not supported, so I have to find a equivalent regex expression of it. Is there any way to match any word after the word git
without using positive lookbehind?
For example, I want to do this without positive lookbehind.
"git checkout master" -> only "checkout"
"git log --graph" -> only "log"
"anything after the word git matches" -> only "matches"
Also, I cannot use group because I can't tell Prism to choose certain group. It will always highlight the whole match.
For example, (?:git )(\w+)
will save any word after the word git
in the first group, but it matches the word git and the word after git. So it will highlight
"git checkout master" -> "git checkout"
"git log --graph" -> "git log"
"anything after the word git matches" -> "git matches"
and this is not what I want.