Hum..., you don't seem to be "in a hurry", @OP, fair enough...
, but I'll be "gone" for the "Evening" for quite several hours to some Open Air Festival... I'll check the Thread again once I'm back, if I'm not too tired, ah-ah...!, or "tomorrow"...
But I won't answer your Thread myself until you've mentioned your OS (even if it very probably won't play any Role for this current Case/Thread), but "take the good Habit" of mentioning your FCI when you open a Thread, especially if I've asked for it, I usually don't even read the Qt and certainly don't answer if that Info is not mentioned, I'm being "nice" this time as it's your 1st Post but I usually don't react normally...).
+ Need to mention FCI on SOF also.
+ Need to post your Script and 'EVAL()' Statement(s)..., and explain a bit what you've tried and what the Issue is actually... It's not clear to me at this moment, if your 'REGEX' Expressions don't return the "expected" Output, or if you don't know how to construct the 'EVAL()' Statements, etc...?
+ I will probably let @thecoder1202 post his Solution(s) first, before posting mine, ah-ah...!
[I can think of at least 10 different Solutions, re-ah-ah...!