Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
66 views
in Technique[技术] by (71.8m points)

javascript - Check if string has unicode 'u25CF'

I want to detect a unicode and format it to next line. To make it look bulleted. Here's the sample text that renders from the database. I'm using AntD and ReactJS.

I'm thinking if I can use this toString.replace()

enter image description here

const renderColumn = (text, record, index, rowKey, cardKey) => {
 return (
   <Form.Item>
    {getFieldDecorator(`${rowKey}-${cardKey}-${index}`, {
      initialValue: text, // THIS IS WHERE THE TEXT RENDER
      rules: [
        {
          required: true,
          message: '*Please fill out this field!',
        },
      ], 
    }
   </Form.Item>
 )
}
question from:https://stackoverflow.com/questions/65650881/check-if-string-has-unicode-u25cf

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In this example I used split() and join() methods. I hope this code works for you.

Example:

var mssg = document.querySelector('div').innerHTML;
mssg = mssg.split('●').join("<br>&#x25CF;");
document.querySelector('div').innerHTML = mssg;
<div>
    &#x25CF; Lorem ipsum dolor &#x25CF; Sit amet consectetur adipisicing elit &#x25CF; Sapiente eum, ut quas accusantium quasi
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...