- This topic has 3 replies, 2 voices, and was last updated 3 years ago by Diego Pérez.
- AuthorPosts
- 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.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)
——————————————————————————————November 3, 2021 at 4:59 pm #59788Diego PérezModeratorHi!
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 #59800jingjohn77Participanthi yes I am, could you help me if I want to use python 3, what would be the regular expression pattern? thank you
November 4, 2021 at 4:38 pm #59804Diego PérezModeratorHi!
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 - AuthorPosts
- You must be logged in to reply to this topic.