Hay,
I'm trying to achieve the below using regex but it looks too complex.
Input: Hello, @[John Doe](600f2e41-0e31-4864-cb18-f8b255788f1c) please confirm with @[Rose Marie](600f2e41-0e33-6864-ab86-f8b255788f1c)
Output: Hello, <span>@John Doe</span> please confirm with <span>@Rose Marie</span>
This is the solution:
const comment = 'Hello, @[John Doe](600f2e41-0e31-4864-cb18-f8b255788f1c) please confirm with @[Rose Marie](600f2e41-0e33-6864-ab86-f8b255788f1c)';
const regex = /@\[(.*?)\]\(.*?\)/g;
return comment.replaceAll(regex, '<span>@$1</span>');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.