Is there any way that just match the string of second group by just using regex?
The tool I'm using is Rundeck's Global Log Filters (Hightlight Output)
Tool description:
Regular Expression to test. Use groups to selectively highlight. More Use a non-grouped pattern to highlight entire match:
regex: test message: this is a test result: this is a test Use regex groups to only highlight grouped sections:
regex: this (is) a (test) result: this is a test See the Java Pattern documentation.
Example:
3) Manager port: 2614
4) Tcp Port: 2615
3) Manager port: 2714
4) Tcp Port: 2715
Above is the strings, I want to get the match of "3) Manager port: 2714"
only. Here is what I come up (?:Manager port:.*){1}
But it still matching both 3) Manager port: 2614
and 3) Manager port: 2714
Thanks
[\s\S]*\KManager port:.*
– Wiktor StribiżewString.startsWith()
would do the trick. – Nir Alfasi