Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Visual C#:
- string testInput = null;
- //The key indicates the lenght of the prefix to check, and the value contains an array
- //with the prefixes to check.
- Hashtable prefixes = new Hashtable();
- prefixes.Add(6, new string[] { "LEJL. " });
- prefixes.Add(5, new string[] { "LEJH ", "LEJL ", "LEJ. ", "VRL. " });
- prefixes.Add(4, new string[] { "DØR ", "LEJ ", "DOR ", "VÆR ", "VÆR." });
- prefixes.Add(3, new string[] { "NR " });
- prefixes.Add(2, new string[] { "D ", "L ", "V " });
- prefixes.Add(1, new string[] { "D" });
- foreach (DictionaryEntry prefixRange in prefixes)
- {
- int lenght = (int)prefixRange.Key;
- if (input.Length > lenght && testInput == null)
- {
- foreach (string prefix in (string[])prefixRange.Value)
- {
- if (input.Substring(0, lenght).ToUpper().Equals(prefix) == true)
- {
- testInput = input.Substring(lenght);
- }
- }
- }
- }
- Ruby:
- testInput = nil
- prefixes = ["LEJL. " , "LEJH ", "LEJL ", "LEJ. ", "VRL. ","DØR ", "LEJ ", "DOR ", "VÆR ", "VÆR.", "NR ", "D ", "L ", "V ", "D" ]
- prefixes.each do |prefix|
- testInput = input.gsub(/^#{prefix}/,"") if !(input =~ /^#{prefix}/).nil?
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement