Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

regex puzzle 1

Status
Not open for further replies.

blacknred

Technical User
Nov 24, 2010
12
IN
Hi,

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

0x0000000a in this case.

Code:
>>> 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...


 
Code:
>>> strH="My values are value=0x00000000 0x00000000 0x00000a00 0x00000000 0x00000000 0x00000000"

>>> strP='0x0+[1-9a-z]0*\s'
>>> lstM=re.findall(strP,strH)
>>> lstM
['0x00000a00 ']
>>>

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top