So I have this string [14:42:49] Any Nick Name: Message bla bla and the only thing I want is Any Nick Name.
I was never really good at regex and I can’t remember how to get a specific part of the result. I came this far: /\[([0-9]{2}(:|\])){3} (.+):/g resulting in [14:42:49] Any Nick Name:.
Well sure I could remove the last and first part with substr and so on, but isn’t there an easier way ?
Your regexp is almost correct.
This matches
[xx:xx:xx] something:withxbeing digits. The^means that the string should start there, and\dmeans a digit. Thegflag doesn’t add anything here.Use
.exec, and use[1]to get the first group (the characters matched inside the parens):