Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm rusty on my Regex and in a time crunch. I need to remove carriage returns from a string but NOT carriage return-line feeds.

It's for a mirth engine so it's javascript...any one help me out?

What I have tried:

lots of google, but not finding my specific scenario.

message = message.replace(???, "");
Posted
Updated 13-Sep-19 8:04am

Try
JavaScript
message=message.replace(/\n(?!\r)/,"")
 
Share this answer
 
Comments
Patrice T 13-Sep-19 14:05pm    
+5, directly to the point.
CPallini 16-Sep-19 3:29am    
Thank you.
Just a few interesting links to help building and debugging RegEx.
Here is a link to RegEx documentation:
perlre - perldoc.perl.org[^]
Here is links to tools to help build RegEx and debug them:
.NET Regex Tester - Regex Storm[^]
Expresso Regular Expression Tool[^]
RegExr: Learn, Build, & Test RegEx[^]
Online regex tester and debugger: PHP, PCRE, Python, Golang and JavaScript[^]
This one show you the RegEx as a nice graph which is really helpful to understand what is doing a RegEx: Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]
This site also show the Regex in a nice graph but can't test what match the RegEx: Regexper[^]
 
Share this answer
 
Comments
CPallini 16-Sep-19 3:30am    
"Teach a man to fish, and you feed him for a lifetime",
5.
Patrice T 16-Sep-19 6:55am    
Thank you
Kschuler 1-Oct-19 9:43am    
Nice. I lost all my regex bookmarks a while back and haven't gotten around to re-bookmarking those tools. Thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900