Make string in paragraph between two delimiters bold javascript JSX
P粉294954447
P粉294954447 2023-09-15 09:31:23
0
1
595

From the database, we get the string in the following format.

_This is string from DB_. Make sure this is format from DB

Now, on JSX/javascript, I want to set the string between two underscores to bold (this is the string from the database in bold format)

P粉294954447
P粉294954447

reply all(1)
P粉573943755

You can use a regular expression to match a string between two underscores and wrap it with a label. You can do this using the string object's replace method. For example, you can modify the code like this:

const dbString = "_This is string from DB_. Make sure this is format from DB";
const formattedString = dbString.replace(/_(.*?)_/g, "<b></b>");
return <div dangerouslySetInnerHTML={{ __html: formattedString }} />;
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template