CSharp · Console
using System;
using System.Text.RegularExpressions;
public class Program
{
public static void Main()
{
string input = "STEAM_1:1:66138017";
//string input= "";
var id = TranslateSteamID(input);
//Correct result according to https://developer.valvesoftware.com/wiki/SteamID :
// 76561198092541763
Console.WriteLine(id);
}
public static Int64 TranslateSteamID(string steamID)
{
Int64 result = 0;
var template = new Regex(@"STEAM_(\d):([0-1]):(\d+)");
var matches = template.Matches(steamID);
if (matches.Count <= 0) return 0;
var parts = matches[0].Groups;
if (parts.Count != 4) return 0;
Int64 x = Int64.Parse(parts[1].Value) << 24;
Int64 y = Int64.Parse(parts[2].Value);
Int64 z = Int64.Parse(parts[3].Value) << 1;
result = ((1 + (1 << 20) + x) << 32) | (y + z);
return result;
}
}