Link to home
Start Free TrialLog in
Avatar of Garbonzo_Horowitz
Garbonzo_HorowitzFlag for United States of America

asked on

Adding a space to a carriage return line feed in JQuery

Hello experts. I would like to know how to add a space to every Line Space Carriage Return with JQuery.
I have two textarea boxes. I want to take the contents of the original one and add a space to every CR LF into the second one.
This is what I have so far but it's not working correctly:

		var original = $("#myTextbox").val();
		var fixed = original.replace( /[\r\n]+/gm, \n+" " );
		$('#myTextbox2').val(fixed);

Open in new window


Any guidance is appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Garbonzo_Horowitz

ASKER

Perfect. Thanks Michel.