Is there a simple way to remove newlines and carriage returns from strings?

is there a simple way to remove newlines and carriage returns from strings?

lksjdflksdjfk/n\r\r\n

1 Like

Hi Hayden,

It’s not exactly simple, but using the Advanced Regex plugin, you can do a Find and Replace of a pattern. Rapid7 Extensions

Using the pattern [\r\n] and replacements set to 0 (unlimited) and replacement text left blank, all newlines should be removed from the input string.

We’ve talked about making this easier! Let us know if you have any suggestions or feedback. Thanks.

that didn’t work for me, this is playing hardball since the character is an escape maybe??

Ive tried using str.translate, re.sub and none work they give either “bad character escape” or “error EOL while reading string literal”

def run(params={}):
import re

output ='{{["input"].[input]}}'
line = re.sub('\','',output)

out = line.strip()


return {"output":out}