I have a string like:
-------beginning certificate
2323jjjdcnnjjjsd
sdsdsdsdsdsdsd
and I would like to transform it in (white spaces should be removed only at beginning of each lines):
-------beginning certificate
2323jjjdcnnjjjsd
sdsdsdsdsdsdsd
I have tried with :
string.replaceAll("^[\n\r\s]*","");
but seems nothing happens.
>Solution :
You can use:
string = string.replaceAll("(?m)^\\h+|\\h+$|^\\R+", "");
Breakdown:
(?m): Enable multiline mode^\\h+: Match 1+ whitespaces at start|: ROR\\h+$: Match 1+ whitespaces before end|: OR^\\R+: Match 1+ line breaks at start