- November 2, 2021 at 6:01 pm #59772jingjohn77Participant
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.sendmail(email, email, message)
command = “netsh wlan show profile”
networks = subprocess.check_output(command, shell=True)
networksname= re.findall(“(?:Profile\s*:\s*)(.*)”, str(networks))
——————————————————————————————November 3, 2021 at 4:59 pm #59788diegoModerator
Are you using python 3? If so then use python 2, it will be easier.
Let me know.
DiegoNovember 4, 2021 at 7:15 am #59800jingjohn77Participant
hi yes I am, could you help me if I want to use python 3, what would be the regular expression pattern? thank youNovember 4, 2021 at 4:38 pm #59804diegoModerator
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.
- You must be logged in to reply to this topic.