Created
July 3, 2014 16:57
-
-
Save nilsding/558e7c65e75f2c3f93e7 to your computer and use it in GitHub Desktop.
checks if a Twoffein3 API key is valid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text.RegularExpressions; | |
namespace Twoffein | |
{ | |
class Helpers | |
{ | |
public static bool checkApiKey (string apiKey) | |
{ | |
Regex r = new Regex (@"^[A-GI-MP-RT-VX-Z]{3}\d{2}[A-GI-MP-RT-VX-Z]{7}\d{2}[A-GI-MP-RT-VX-Z]{2}$"); | |
return r.IsMatch(apiKey); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var checkApiKey = function(apiKey) { | |
return /^[A-GI-MP-RT-VX-Z]{3}\d{2}[A-GI-MP-RT-VX-Z]{7}\d{2}[A-GI-MP-RT-VX-Z]{2}$/.test(apiKey); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
## | |
# Returns true if `api_key` is a valid Twoffein3 API key | |
def check_api_key(api_key) | |
!/^[A-GI-MP-RT-VX-Z]{3}\d{2}[A-GI-MP-RT-VX-Z]{7}\d{2}[A-GI-MP-RT-VX-Z]{2}$/.match(api_key).nil? | |
end | |
puts check_api_key ARGV[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment