angular.js - How to obtain the specified characters in a certain text using angular, regular expressions or other methods
PHP中文网
PHP中文网 2017-05-15 17:08:00
0
1
596

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中文网

认证高级PHP讲师

reply all(1)
世界只因有你
'<p>名族特色[pig_12] [pig_12] [pig_12][smiley_1] [smiley_1] [smiley_4] [smiley_6]</p>'.replace(/\[(.+?)\]/g,'<img src="">')
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template