Hope all of you are doing nice and being safe.
I'm using node JS and what I want to achieve is the following: I want to make an array with all the ocurrences that matches a certain regex. I want to find in a string all the ocurrences of numbers that have a format like this one: %{00001}
For example, if I have the following text:
Example text %{00001} with some %{00002} examples %{00003}
The match method should return the following array with three elements:
["%{00001}" , "%{00002}" , "%{00003"]
This is the code I am using currently. The problem is that I only obtain the first value it gets. For this example, it returns an array with %{00001}, that's all. And supposedly, this method can find all the ocurrences and make an array, so my guess is that I'm probably using it wrong. I tried this regex in the regex101 website and it returns three matches, so now I'm a little confused and I would appreciate some help.
let textRegex = "This is a test: %{00000} This is the name: %{00003} . This is the description: %{00001}";
let arrayRegex = textRegex.match("%{[0-9]{5}}").map(String);
What am I doing wrong? I made several searches before making this post, but couldn't find anything that helps me :(
Thanks for your help!
Best regards, Sergio