-3

i would like your help to help me create a regex that will replace each "\r\n" syntax to a new line, like this example:

POST / HTTP/1.0\r\nHost: mywebsite.net\r\nConnection: close\r\nContent-Length:
400\r\nContent-Type: text/xml; charset=utf-8\r\nUser-Agent: Apache-
HttpClient/4.5.1 (Java/1.8.0_74)\r\nAccept-Encoding: gzip,def1ate

To this:

POST / HTTP/1.0
Host: mywebsite.net
Connection: close
Content-Length: 400
Content-Type: text/xml; charset=utf-8
User-Agent: Apache-HttpClient/4.5.1 (Java/1.8.0_74)
Accept-Encoding: gzip,deflate

many thanks!

4
  • Please provide more details on where you are trying to write your Regex. Commented May 26, 2016 at 18:12
  • What language are you using? Commented May 26, 2016 at 18:15
  • You don't need regex to solve your problem. Just use simple plain-text replacement in whatever language you're using. For example in java: String formatted = str.replace("\\r\\n", "\n"); or replace with "\r\n" as you like Commented May 26, 2016 at 18:18
  • Possible duplicate of replace '\'n in javascript Commented May 26, 2016 at 18:20

1 Answer 1

0

Sorry for that. I am using java pattern class to evaluate regular expressions. It is on a graylog system that collect the access log (request and response) from the server. extractor configuration

I was trying to make \\r\\n and replace with \r\n but it didnt help.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.