In java, how to write a regex to take first 3 lines if there is more than 3 lines OR take all lines if there is less than or equal to 3 lines?
I used the https://regexr.com/ to verify my own solution, failed. Then I asked the online chat group IRC #regex, the expert gives me answer within 1 minute. So I believe I shall share the knowledge here.