String splitting in python by finding non-zero character -


i want following split:

input: 0x0000007c9226fc output: 7c9226fc input: 0x000000007c90e8ab output: 7c90e8ab input: 0x000000007c9220fc output: 7c9220fc 

i use following line of code not work!

split = element.rpartition('0') 

i got these outputs wrong!

input: 0x000000007c90e8ab output: e8ab input: 0x000000007c9220fc output: fc 

what fastest way kind of split? idea me right make loop , perform checking little time consuming.

i should mention number of zeros in input not fixed.

each string can converted integer using int() base of 16. convert string.

for s in '0x000000007c9226fc', '0x000000007c90e8ab', '0x000000007c9220fc':     print '%x' % int(s, 16) 

output

 7c9226fc 7c90e8ab 7c9220fc 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -