Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

regex puzzle

regex puzzle

regex puzzle


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


RE: regex puzzle


>>> 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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close