Hi,

I'm trying to 'grep' the string which comprises of all non-zero values

0x0000000a in this case.

>>> match = re.search('0x0000000[1-9,a-z]', "My values are value=0x00000000 0x00000000 0x0000000a 0x00000000 0x00000000 0x00000000")

This works but in this case, but not over any string as in if example is:

"My values are value=0x00000000 0x00000000 0x00000a00 0x00000000 0x00000000 0x00000000")

This wont pick out 0x00000a00 correctly ,

What would be the regex for picking out the string that doesNOT match pattern '0x00000000'?

Thanks in advance...

I suggest

re.search(r'0x0*[1-9a-f][0-9a-f]*', ...)

I suggest

re.search(r'0x0*[1-9a-f][0-9a-f]*', ...)

This works. Thanks a lot.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.