regex - How do I match an entire string to replace it with its components? -


ok, have been fiddling on regexr.com long while , i'm still having no joy.

this 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 want do, replace entire string each number. so... run regex once, , replace string 7792. run again , replace 783. run again, replace 5365514 , on.

how build first, second , third regex? can work out form there...

the numbers parts of change. rest stay same anytime run.

ok, have worked out solution though not best. still wondering if has better option this, posting might useful out there somewhere?

this 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+)\,-?(\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+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s-?(\d+)\,-?(\d+)\s.* 

i have 125 groups use replace see fit purpose. :) works in regexr here: http://regexr.com/3a0cm


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -