ALERT!
Click here to register with a few steps and explore all our cool stuff we have to offer!

Jump to content



Photo

[Question] Need help with Regex Python


  • Please log in to reply
[Question] Need help with Regex Python

#1

senowx
senowx
    Offline
    16
    Rep
    275
    Likes

    pls gibe a rank

Posts: 1207
Threads: 83
Joined: Jan 07, 2019
Credits: 0

Five years registered
#1

I'm trying to make a email:pass to user:pass converter on python, using regex

 

Heres is the code:

import re
line = tr = open('test.txt', 'r').read()
match = re.findall(r'[\w\.-]+@[\w\.-]+' + r':[\w\.-]+', line)
f = open('output.txt', 'w')
for i in match:
    i = i.lower()
    print(" ", i)
    f.write(i + '\n')
f.close()

Output is: [email protected]:password

 

I need help to remove "@gmail.com" and special characters...


  • 0

?url=https%3A%2F%2Fi.imgur.com%2FZba0FXq


#2

TheNightmareEU
TheNightmareEU
    Offline
    9
    Rep
    140
    Likes

    Pizdets, dont make me pull out the hui

Posts: 40
Threads: 9
Joined: Feb 11, 2020
Credits: 0

Four years registered
#2
Are you trying to split the line using the : delimiter?

Also you can use re.compile function() and then search the string with re.search()

  • 1

#3

senowx
senowx
    Offline
    16
    Rep
    275
    Likes

    pls gibe a rank

Posts: 1207
Threads: 83
Joined: Jan 07, 2019
Credits: 0

Five years registered
#3

Are you trying to split the line using the : delimiter?

Also you can use re.compile function() and then search the string with re.search()

Yeah.

 

I'll try to use re.compile and search. Im new on python ;)

 

Really appreciate your contribution.


Edited by senowx, 14 February 2020 - 08:42 PM.

  • 0

?url=https%3A%2F%2Fi.imgur.com%2FZba0FXq


#4

TheNightmareEU
TheNightmareEU
    Offline
    9
    Rep
    140
    Likes

    Pizdets, dont make me pull out the hui

Posts: 40
Threads: 9
Joined: Feb 11, 2020
Credits: 0

Four years registered
#4

Yeah.
 
I'll try to use re.compile and search. Im new on python ;)
 
Really appreciate your contribution.


I learned python today aswell! Had to automate a task and couldnt stand paying 40 usd for the script!

I hope you will find the answer to ur question. Of re.search and re.compile dont work @ me and ill help u further

  • 1

#5

DarkStarWarden
DarkStarWarden
    Offline
    2
    Rep
    109
    Likes

    Veteran

Posts: 804
Threads: 49
Joined: Nov 06, 2017
Credits: 0

Six years registered
#5

I'm trying to make a email:pass to user:pass converter on python, using regex

 

Heres is the code:

import re
line = tr = open('test.txt', 'r').read()
match = re.findall(r'[\w\.-]+@[\w\.-]+' + r':[\w\.-]+', line)
f = open('output.txt', 'w')
for i in match:
    i = i.lower()
    print(" ", i)
    f.write(i + '\n')
f.close()

Output is: [email protected]:password

 

I need help to remove "@gmail.com" and special characters...

import re
with open("combo.txt") as f:
    combos = f.read().splitlines()

with open("converted_combo.txt", "w") as f:
    for line in combos:
        x = re.search(r"([\w\.-]+)@[\w\.-]+" + r'(:[\w\.-]+)', line)
        if (x): #If it's email:pass combo it will only write the password and the stuff before the @Email
            print(line + " --> " + x[1] + x[2] )
            f.write(x[1] + x[2] + "\n")

        else: #If it's a user:pass combo it will still write it to the file
          print(line)
          f.write(line + "\n")

Tell me if this works


  • 1

#6

senowx
senowx
    Offline
    16
    Rep
    275
    Likes

    pls gibe a rank

Posts: 1207
Threads: 83
Joined: Jan 07, 2019
Credits: 0

Five years registered
#6
import re
with open("combo.txt") as f:
    combos = f.read().splitlines()

with open("converted_combo.txt", "w") as f:
    for line in combos:
        x = re.search(r"([\w\.-]+)@[\w\.-]+" + r'(:[\w\.-]+)', line)
        if (x): #If it's email:pass combo it will only write the password and the stuff before the @Email
            print(line + " --> " + x[1] + x[2] )
            f.write(x[1] + x[2] + "\n")

        else: #If it's a user:pass combo it will still write it to the file
          print(line)
          f.write(line + "\n")

Tell me if this works

 

Wow dude, it worked very well.

 

Really appreciate your help <3


  • 0

?url=https%3A%2F%2Fi.imgur.com%2FZba0FXq


#7

unazed
unazed
    Offline
    31
    Rep
    126
    Likes

    https://rari.su

Posts: 285
Threads: 29
Joined: Sep 17, 2018
Credits: 0

Five years registered
#7

xchng#5401


  • 0

Contact for professional programming services.

 

6+ years desktop application development experience.
Python and C, reverse engineering experience on x86{-64} native binaries.
Versed in penetration testing, CompTIA Network+ certified.

Discord: xchg#5401

 

Your one-stop-shop for homework help: PaperPeers.com



 Users browsing this thread: