Skip to content

Instantly share code, notes, and snippets.

@foldi
Created October 4, 2013 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foldi/6828805 to your computer and use it in GitHub Desktop.
Save foldi/6828805 to your computer and use it in GitHub Desktop.
Magic regex
colors = {
empty: 0,
brown: 1,
green: 2,
blue: 3,
cyan: 4,
magenta: 5,
yellow: 6,
black: 7,
gray: 8
};
items = {
2: {
'/^[^0-9]*7[^0-9]*1[^0-9]*$/': 'torch'
},
3: {
'/^[^0-9]*3[^0-9]*3[^0-9]*1[^0-9]*$/': 'wooden sword',
'/^[^0-9]*4[^0-9]*1[^0-9]*5[^0-9]*$/': 'arrow',
'/^[-]*222[-]*$/gm': 'paper'
},
5: {
'/^[^0-9]*666[^0-9]*1[^0-9]*1[^0-9]*$/': 'gold pickaxe',
'/^[^0-9]*88[^0-9]*81[^0-9]*1[^0-9]*$/': 'iron axe'
},
8: {
'/^[^0-9]*333[^0-9]*3[^0-9]*3[^0-9]*333[^0-9]*$/': 'chest'
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment