How to combine an entire string to replace it with its components?

advertisements

OK, so I have been fiddling with this on regexr.com for a long while now and I'm still having no joy.

This is my sample data:

<html><body><p>7792,783,5365514 -1,1,-1 6329,46,72141 -1,1,-1 8595,42,49104 -1,1,-1 14386,21,5026 6172,52,128182 6311,51,114826 9108,43,51437 8257,24,7050 5289,55,169099 -1,1,-1 15667,26,8919 29,79,1861956 32,83,2681719 4595,32,16506 8469,22,6113 -1,1,-1 -1,1,-1 -1,1,-1 7912,50,102981 -1,1,-1 6951,15,2579 -1,1,-1 4830,46,70571 6617,24,7553 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 </p></body></html>

What I want to do, is replace the entire string with each number. So... I will run the regex once, and replace the string with 7792. then Run it all again and replace with 783. Run it again, replace with 5365514 and so on.

How would I build the first, second and third regex? I can work it out form there...

The numbers are obviously the only parts of this which will change. the rest will stay the same anytime this is run.


OK, so I have finally worked out A solution though it is clearly not the best. I am still wondering if anyone has a better option than this, but posting this so that it might be useful out there somewhere?

This is my regex:

<(?:[\s\S]+)>-?(\d+)\,-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\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