Asked thg 9 16, 2021 8:52 SA 110 0 2
  • 110 0 2
0

Replace String in String

Share
  • 110 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 thg 9 16, 2021 4:07 CH
+1

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

image.png

Share
Answered thg 9 29, 2021 9:41 SA
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.