0

I am receiving a comments from service. If I get this comment "hello world" it is printing as it is but when I receive Comments like this "hello

world" then I am receiving nothing I write a function for it but it also doesn't work

function NextLineFix(Call) {

        return Call.replace("\n", '<br>');
    }

Can any body help please....!

3 Answers 3

2

Perhaps you also have carriage return characters in the string ('\r')? Does this work better for your issue:

Call.replace("\r", "").replace("\n", "<br/>") ?
Sign up to request clarification or add additional context in comments.

Comments

2

try this:

function NextLineFix(Call) {    
    return Call.replace(/[\r\n]/gi, '<br/>');
}

2 Comments

In this function i am unable to print "" means i want to print the whole text "hello" including "" how can i achieve this can you please solve this????
try this: return '"' + Call.replace(/[\r\n]/gi, '<br/>') + '"';
0

Try it with \r\n instead of \n and then do the replace , see if that helps

2 Comments

Can you check to see what is in call variable? Does it contain the hello world? or does it show unterminated string constant?
it has "hello world" and remains hello world no change occur

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.