I'm interested in enhancing a regex in JavaScript that detects new lines or line breaks and converts them to carriage returns. - Yep, Photoshop's text feature is a bit outdated.
- "hello\nworld"
- "hello
world"
All of the above examples should be replaced with
-hello/rworld
I understand that the second example above is treated as an actual line break
So far, I've had to use two separate regex patterns, but I'm really looking for a single one that can handle both scenarios (multiple times). However, I haven't been successful in combining them effectively.
// replace \n with \r carriage return
var rexp = new RegExp(/\\n/gi)
content = content.replace(rexp , "\r")
// replace <br> with \r carriage return
rexp = new RegExp(/<br>/gi)
content = content.replace(rexp , "\r")
Thanks.