an external program generates a file for me like this:
"lorem ipsum",
"lorem ipsum",
"lorem ipsum",
"lorem ipsum"
and I want to obtain:
"lorem ipsum",
"lorem ipsum",
"lorem ipsum",
"lorem ipsum"
I would like to remove these free spaces made by creating a new line, I was thinking about regex but I have no idea how to do it.
I tried regex but didn’t find query
2
Answers
In PHP function
preg_replace
is used for replacing by regex. Actual regex is based matching multiple consecutive new line (n
) by single one.The idea: match all white-space sequence greedily and let the regex engine backtrack if needed until an end of line.
Pro:
Cons:
~As*R|s+$~mu
)