Regex to replace the last n delimiters in record -


i have csv file records this:

^tablete internet^|goclever|^tab i71^|^tableta goclever tab i71, infotmic imapx220 1ghz mkv, mov, vob, dat, wmv, avi, 3gp, mp4, rm, rmvb, flv, mkv, mov, vob, dat, wmv, mp3!wav!ogg!flac!ape!aac, conectori: 1x mini jack 3.5 mm, 2 porturi usb 2.0, 4000 mah lithium-ion polymer 3.7v^!92.00!usd!w!24!0!link!!^5 ron^!!| group|prod|den|description!12!eur!^wait time^!160!modified!link!^spec obs^!^tv none^!more!info| 

i need replace last 10 of "!" end of row "|" finaly like:

^tablete internet^|goclever|^tab i71^|^tableta goclever tab i71, infotmic imapx220 1ghz mkv, mov, vob, dat, wmv, avi, 3gp, mp4, rm, rmvb, flv, mkv, mov, vob, dat, wmv, mp3!wav!ogg!flac!ape!aac, conectori: 1x mini jack 3.5 mm, 2 porturi usb 2.0, 4000 mah lithium-ion polymer 3.7v^|92.00|usd|w|24|0|link||^5 ron^||| group|prod|den|description|12|eur|^wait time^|160|modified|link|^spec obs^|^tv none^|other|info| 

i've tried with:

sed 's/!\([^\^!]*\)!\([^!]*\)$/|\1|\2/' 

but replaces last 2 occurences of "!". if try

sed 's/!\([^\^!]*\)!\([^!]*\)!\([^!]*\)$/|\1|\2\3/' 

it not match anything... how can this?

thanks!

here go http://refiddle.com/2l5


Comments