Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix get_steam_id() #293

Merged
merged 1 commit into from
Sep 28, 2023
Merged

fix get_steam_id() #293

merged 1 commit into from
Sep 28, 2023

Conversation

makarworld
Copy link
Contributor

Test case:

import re

# fixed
def search_get_steam_id() -> int:
    text = '    g_steamID = "76561198085278322";'
    steam_id = re.search(r'g_steamID = "(\d+)";', text)
    if steam_id:
        return int(steam_id.group(1))
    else:
        raise ValueError('Invalid steam_id: {}'.format(steam_id))

# not fixed
def match_get_steam_id() -> int:
    text = '    g_steamID = "76561198085278322";'
    steam_id = re.match(r'g_steamID = "(\d+)";', text)
    if steam_id:
        return int(steam_id.group(1))
    else:
        raise ValueError('Invalid steam_id: {}'.format(steam_id))

print(search_get_steam_id())
# 76561198085278322
print(match_get_steam_id())
# ValueError: Invalid steam_id: None

@bukson bukson merged commit fc3267b into bukson:master Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants