0

This is the string I have:

"
Store: Tailor Shop (1)
Send complete welcome package
Datasheet was completed at 01.01.2000"

How can I convert it to

"Store: Tailor Shop (1)
Send complete welcome package
Datasheet was completed at 01.01.2000"

?

connexo
  • 53,704
  • 14
  • 91
  • 128
  • 1
    Possible duplicate: http://stackoverflow.com/questions/10805125/how-to-remove-all-line-breaks-from-a-string or this: http://stackoverflow.com/questions/14572413/remove-line-breaks-from-start-and-end-of-string – Alexis Tyler Aug 13 '15 at 06:26
  • 1
    `String.prototype.trim` – dfsq Aug 13 '15 at 06:28
  • 1
    `trim` did it! I thought that was supposed to only remove white-space, resp. I wasn't aware that newline counts as white-space. – connexo Aug 13 '15 at 06:34
  • Does this answer your question? [How do JavaScript closures work?](https://stackoverflow.com/questions/111102/how-do-javascript-closures-work) – Protect children of Donbas2014 Apr 09 '21 at 13:08

1 Answers1

1

You may try this,

string.replace(/\n/, '')

Regex without g modifier would remove only the first newline character.

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274