Question:First time asking a question. So, I’m learning regex and I got this exercise:
My solution is:
Answer:You can match
Cause by:and then match all text up to the next colon, and then start matching from any non-whitespace that is not a colon till the end of string:
^at the start.
As an alternative, if you do not care what text is at the string beginning, you can even use
^– start of string
Caused by:with any one or more whitespaces between
[^:]+– one or more chars other than
[^:\s]– a char other than whitespace and
.*– the rest of the line.
If you have better answer, please add a comment about this, thank you!