I am fetching some data from an API. One of the results is this string:
| Experience Points | Level | Proficiency Bonus |
I've been trying to use RegEx with replace() to have each string between | | in a tag. So far I was able to have the first and last inside the tag, but I fail to have the middle string inside the tag. Can someone point out what I am doing wrong and maybe help me with a solution? I've been stuck on this for days. I'd really appreciate it.
This is what I have done so far:
replace(/\|\s(\D*?)\|/g, "<span>$1</span>")
It gives me the following result:
<span> Experience Points </span> Level <span> Proficiency Bonus </span>
This is what I expect:
<span> Experience Points </span> <span> Level </span> <span> Proficiency Bonus </span>
Thank you all for the help.