I have a problem breaking down 1 line using <br />
, I have converted to string but it doesn't work. I have followed this https://stackoverflow.com/questions/63574937/how-to-convert-html-string-into-plain-text-in-react
answer to follow edit, it still doesn't work.
This intl.formatMessage({ id: "AUTH.LOGIN.DESCRIPTION.1" }) is System may takes some time to generate the email. Kindly login when you had received the email. <br /> Thank you for your understanding and apologise for the inconvenience caused.
const htmlFormatMessage = intl.formatMessage({ id: "AUTH.LOGIN.DESCRIPTION.1" });
const htmlString = htmlFormatMessage;
const plainString = htmlString.replace(/<br\/>/gi, '\n');
<p className="text-muted font-weight-bold">
{plainString}
</p>
Now my result is shown below:
I want the actual result to be shown below:
` you're matching only `
` – VLAZ May 13 '22 at 08:44
/gi, '\n'); – Fatt Sky May 13 '22 at 08:53
]+>/gi, '\n')` should do the trick, it matches any content inside your `
`, it could have a class or spaces – savageGoat May 13 '22 at 08:55
` in your text) into a proper `
` DOM element. React does that do avoid HTML injections – savageGoat May 13 '22 at 09:02
]+>/gi, '\n\n')` to display not only a break line but an empty line following your break (having your CSS with `white-space: pre-line;`) – savageGoat May 13 '22 at 09:14
]+>/gi, '\n\n');` still cannot jump to next line – Fatt Sky May 13 '22 at 09:17