Asked Sep 16th, 2021 8:52 a.m. 85 0 2
  • 85 0 2
0

Replace String in String

Share
  • 85 0 2

Chào mọi người, mình có một vấn đề nhỏ xin mọi người giúp đỡ với ạ.

Mình đang làm chức năng search và highlight text, mình thực hiện replace như sau:

"<a href="&quot;mailto:support@seesoop.com&quot;">support@seesoop.com</a>".replaceAll('support@seesoop.com','<span>support@seesoop.com</span>')

Kết quả hiện tại là: <a href="&quot;mailto:<span>support@seesoop.com</span>&quot;"><span>support@seesoop.com</span></a>

Kết quả mình mong muốn là: <a href="&quot;mailto:support@seesoop.com&quot;"><span>support@seesoop.com</span></a>

Mong mọi người giúp mình với ạ.

2 ANSWERS


Answered Sep 16th, 2021 4:07 p.m.
+1

Bạn thử xem được không

image.png

Share
Answered Sep 29th, 2021 9:41 a.m.
0

#---

'<a href="&quot;mailto:support@seesoop.com&quot;">support@seesoop.com</a>'.replace(/(=?>)(support@seesoop.com)/g,'<span>$2</span>')
Share
Viblo
Let's register a Viblo Account to get more interesting posts.