This is one of my favorite riffs and I play it all the time in the key of E. It sounds flashy and good, but it's also a good exercise for working on your hammer-ons and pull-offs. In fact, that's how I first discovered it. I like this one in the key of E because you have the option of using several open strings, if you like.
Start on the high E string with your index finger on the 3rd fret G note. Pick it and keep your finger there, setting yourself up for the pull off. Now use your ring finger to hammer on (HO) to the 5th fret A note on the same string. Continue the motion with a pull off (PO) to the finger waiting on the 3rd fret. Finish the move by picking the E note on the 5th fret B string. An extra option is to continue the pull off on the Estring and play the open E simultaneously with the E note on the B string. The second section is the same as the first, except this time start the move on the B string 3rd fret and your open string option is the B. The final note of the segment is the B note on the G string 4th fret.
Next is the two fret HO/PO starting on the 2nd fret G string. So the move goes from A to B, back to A and finally a PO to the open G string. Remember it should be a continuous motion while picking only the first note in this case. The lower strings start with the open D string. Then hammer onto the E note 2nd fret with your index finger. Continue with the PO back to the open D string and end with the B note on the 2nd fret A string. The last HO/PO is a repeat of the move I just described, starting on the A string with your last notes being the G on the 3rd fret low E, which you should bend to a blue note and pull off oto the open E string.