'How parse a comment with custom markup to html markup using regex javascript
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>
Solution 1:[1]
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>');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vikas Y |
