// So I've got an array consisting of unique, four digit String numbers (0,1,2 only).
var patterns:Array = ["1111", "2212", "1121", "2222", "1011", "2022", "2021", "1012", "1022", "2012", "1021", "2011", "0022", "0011", "0012", "0021"];
// And I want to match to them a variation of one of
// those elements which have shifted numbers by 1-3 places.
// Example: If I get a generated String number of '2221' I
// want to quickly match it to patterns[1], because it's a
// variation of that pattern, and return the +/- shifted places
// it represents.
// Example 2:
// Search value: '0111'
// Correct pattern: patterns[4], shifted:-1
// Example 3:
// Search value: '2200'
// Correct pattern: patterns[13], shifted:+2
// etc.
Is there a way to do this with RegExp maybe? I know that I could just add each variation of each pattern to the array, and just search it, but I want to do it more intelligently.