Advertisement
DropSquad

Untitled

Aug 10th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. I was messing around with patterns and trying to parse a string for some information.
  2.  
  3. local str = "<water:100> askdjkl< << <<wood:2> <string:3"
  4.  
  5. how would I extract only '<water:100>', '<wood:2>', and '<string:3' from this string?
  6.  
  7. currently:
  8.  
  9. for item in str:gmatch("<.->") do
  10. print(item)
  11. end
  12.  
  13. The problem is that I can't get the last item because the '>' is supposed to be optional at the end of the string only. I've tried messing around with anchors and failed. Another thing I noticed is that for "wood" I get "< << <<wood:2>" even though I used .- to match the shortest sequence possible.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement