search

Home  >  Q&A  >  body text

angular.js - How to obtain the specified characters in a certain text using angular, regular expressions or other methods

In the project, it is necessary to obtain the specified string in a certain text and then replace the obtained characters with the corresponding pictures, for example:

<p>名族特色[pig_12] [pig_12] [pig_12][smiley_1] [smiley_1] [smiley_4] [smiley_6]</p>

How to get [pig_number] and [[smiley_number], and then replace the intercepted characters with the specified picture? The image name is the same as the intercepted string name.

PHP中文网PHP中文网2805 days ago616

reply all(1)I'll reply

  • 世界只因有你

    世界只因有你2017-05-15 17:10:00

    '<p>名族特色[pig_12] [pig_12] [pig_12][smiley_1] [smiley_1] [smiley_4] [smiley_6]</p>'.replace(/\[(.+?)\]/g,'<img src="">')

    reply
    0
  • Cancelreply