I know the usual way I would go about this would be to use Regex, My question being how would I extract all Email and passwords or username and passwords out of a string and put it into a string by itself. Thanks!
If you have mixed contents and you need to recognize a pattern you should use a regex solution, any reason for not using it?
I know that regex is the way to go I just don't know the pattern to use.
DO NOT DEAL WITH THIS MEMBER
Shouldn't it be something like this?
Code string details = "user:pass";
string[] detail = details.Split(':');
string user = detail[0];
string pass = detail[1];
(Dec 29, 2018 07:12 PM)Onireves Wrote: Shouldn't it be something like this?
Code string details = "user:pass";
string[] detail = details.Split(':');
string user = detail[0];
string pass = detail[1];
Only if the data is perfectly delineated by colons. By the sound of the OP though, it's far from that.
(Dec 29, 2018 04:54 PM)-PUBG- Wrote: I know the usual way I would go about this would be to use Regex, My question being how would I extract all Email and passwords or username and passwords out of a string and put it into a string by itself. Thanks!
Show us a sample of the dataset, and we can better work up a potential RegEx pattern.
Dec 29, 2018 10:23 PM
(This post was last modified: Dec 29, 2018 10:26 PM by -PUBG-.)
See that is what I am getting at, I am trying to make it extract in any situation or close to it, So if it has 1,000 lines and there is arandom username/password or email/password like
Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data username:password Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data Data [email protected]:password Data Data Data Data Data Data Data Data Data Data Data
or something such as that.
I guess I don't know the best way to go about it and make it grab them all.
The regex for email is publicly available all over the internet. Why couldn't you combine it with a colon, and a pattern to match the charset used for the passwords?
And if you're splitting by colon, the first colon should be fine because the email probably won't contain one, but a password may, so even the split method above is bugged unless you introduce the count parameter for a value of 2 to avoid it splitting after the first occurrence.
Dec 30, 2018 09:53 AM
(This post was last modified: Dec 30, 2018 09:55 AM by gigajew.)
You could try regular expression. I'm not that good, but here's a start https://rubular.com/r/4JzzeG7g7LhF
if you have like this:
Code DATA DATA DATA DATA DATA [email protected]:password DATA DATA DATA DATA DATA DATA DATA DATA [email protected]:password DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA [email protected]:password DATA DATA DATA DATA DATA DATA test:password DATA DATA DATA DATA DATA DATA DATA test:password DATA DATA DATA DATA DATA
you can use this Regex.
it finds user:pass and mail:pass, but will probably be bugged if there are other : unrelated to user:pass or mail:pass.
Example usage:
Code string data = "DATA here";
List<string> results = new List<string>();
Regex r = new Regex(@"\s?([^\s]*:[^\s]*)");
foreach(Match m in r.Matches(data)){
results.Add(m.Groups[1].Value);
}
code not tested tho(but should be working)
Dec 30, 2018 03:44 PM
(This post was last modified: Dec 30, 2018 03:56 PM by -PUBG-.)
Thank you all for the replies and all of your help :)
(Dec 30, 2018 10:24 AM).TheMarv Wrote: if you have like this:
Code DATA DATA DATA DATA DATA [email protected]:password DATA DATA DATA DATA DATA DATA DATA DATA [email protected]:password DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA [email protected]:password DATA DATA DATA DATA DATA DATA test:password DATA DATA DATA DATA DATA DATA DATA test:password DATA DATA DATA DATA DATA
you can use this
Regex.
it finds user:pass and mail:pass, but will probably be bugged if there are other : unrelated to user:pass or mail:pass.
Example usage:
Code string data = "DATA here";
List<string> results = new List<string>();
Regex r = new Regex(@"\s?([^\s]*:[^\s]*)");
foreach(Match m in r.Matches(data)){
results.Add(m.Groups[1].Value);
}
code not tested tho(but should be working)
This grabs all the data that has a : in it. Which messed it all up.
Here is an example of what I am trying to parse, The email:password out of a file for example in this
http://pasted.co/306daa3b
DO NOT DEAL WITH THIS MEMBER
(Dec 30, 2018 03:44 PM)-PUBG- Wrote: Thank you all for the replies and all of your help :)
This grabs all the data that has a : in it. Which messed it all up.
Here is an example of what I am trying to parse, The email:password out of a file for example in this
http://pasted.co/306daa3b
That's far from the original sample of data you provided.
Dec 30, 2018 05:45 PM
(This post was last modified: Dec 30, 2018 05:46 PM by 0xBB.)
(Dec 30, 2018 03:44 PM)-PUBG- Wrote: Thank you all for the replies and all of your help :)
This grabs all the data that has a : in it. Which messed it all up.
Here is an example of what I am trying to parse, The email:password out of a file for example in this
http://pasted.co/306daa3b
Here how about this pattern:
Code [\w\.-]+@[\w\.-]+:.*
Example ( Repl.it link):
Code using System;
using System.Text.RegularExpressions;
class MainClass {
public static void Main (string[] args) {
var leData = @"
--------------------------------------------------------
-------------------<EpicAccount>------------------------
- Login: [email protected]:suckmyfuckinghugedick4312
--------------------------------------------------------
--------------------------------------------------------
----------------------<Skins>---------------------------
--------------------------------------------------------
=> Havoc
=> Sub Commander
--------------------------------------------------------
----------------------<Back Bling>------------------------
--------------------------------------------------------
=> Backup Plan
--------------------------------------------------------
----------------------<Pickaxes>------------------------
--------------------------------------------------------
=> Default Pickaxe
=> Instigator
--------------------------------------------------------
----------------------<Gliders>------------------------
--------------------------------------------------------
=> Slipstream
=> Default Glider
--------------------------------------------------------
----------------------<Dances>------------------------
--------------------------------------------------------
=> Dance Moves
=> Salute
=> Regal Wave
--------------------------------------------------------
----------------------<Emoji's>------------------------
--------------------------------------------------------
=> Let's Rock
=> In Love
=> Let's Rock
=> Battle Bus
--------------------------------------------------------
----------------------<Loading Screens>------------------------
--------------------------------------------------------
=> Drift
=> Calamity
--------------------------------------------------------
----------------------<Total Item Count>------------------------
--------------------------------------------------------
Total Skins -----> 2
Total BackBling -----> 1
Total Axes -----> 2
Total Gliders -----> 3
Total Dances -----> 3
Total Emoji's -----> 4
Total Loading Screens -----> 2
Total Items On Account -----> 17
--------------------------------------------------------
----------------------<Other Useful Information>------------------------
--------------------------------------------------------
Profile ID: (7814a9e6f315435db396e5bf4d2109da)
Account ID: (1a35a7ba8c614f1e83c405f4e7a6e94c)
Account Creation Date: (2018-03-02 2:12:44 AM)
Game Last Played: (2018-12-18 2:47:51 PM)
LifeTime Wins (0)
Season Level (1)
Account Level (51)
Has Current Battlepass: False
Has Save The World ---> False
Has Vbucks ---> False
Main Platform Used: EpicPC
Platforms Used/Linked:
PC
Can Send Gift: True
Can Recieve Gift: True
Completed 1ST B-Day Challenges: No
Plays On Galaxy Note 9: No
Has Twitch Prime Pack #1: Yes
Has Twitch Prime Pack #2: No
Has Bought Starter Pack: No
Has Mail Access: No
--------------------------------------------------------
----------------------<BattlePass Information>------------------------
--------------------------------------------------------
Had Season 2 BattlePass ---> No
Had Season 3 BattlePass ---> No
Had Season 4 BattlePass ---> No
Had Season 5 BattlePass ---> No
Has Current Battlepass (Season 6) ---> No
--------------------------------------------------------
----------------------<Past Season Info>------------------------
--------------------------------------------------------
Season #3
Season Wins: 0
Season XP: 571
Season Final Level: 22
Had BattlePass: False
Season #4
Season Wins: 0
Season XP: 0
Season Final Level: 1
Had BattlePass: False
Season #5
Season Wins: 0
Season XP: 1116
Season Final Level: 18
Had BattlePass: False
Season #6
Season Wins: 0
Season XP: 550
Season Final Level: 9
Had BattlePass: False
--------------------------------------------------------
----------------------<Account Information>------------------------
--------------------------------------------------------
Account ID: 1a35a7ba8c614f1e83c405f4e7a6e94c
Display Name: Bwr3ck
Email Address: [email protected]
First Name: Brad
Last Name: Bereck
Number Of Failed Logins: 0
Last Login Date: 2018-12-24 5:36:49 AM
Number Of Name Changes: 0
Country: US
Language: en
TFA Enabled: False
--------------------------------------------------------
--------------------DONE CHECKING-------------------------------
--------------------------------------------------------
-------------------<EpicAccount>------------------------
- Login: [email protected]:trashkidfuck213
--------------------------------------------------------
--------------------------------------------------------
----------------------<Skins>---------------------------
--------------------------------------------------------
=> Blue Team Leader
--------------------------------------------------------
----------------------<Back Bling>------------------------
--------------------------------------------------------
--------------------------------------------------------
----------------------<Pickaxes>------------------------
--------------------------------------------------------
=> Default Pickaxe
";
Regex r = new Regex(@"[\w\.-]+@[\w\.-]+:.*");
foreach(Match m in r.Matches(leData)){
Console.WriteLine (m.Value);
}
}
}
Dec 30, 2018 05:55 PM
(This post was last modified: Dec 30, 2018 05:58 PM by Aristocles.)
PHP Code
<?php using System; using System.Net; using System.Text.RegularExpressions;
namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string txt = new WebClient().DownloadString("https://pastebin.com/raw/L7nbhyTT");
string re1 = "([\\w-+]+(?:\\.[\\w-+]+)*@(?:[\\w-]+\\.)+[a-zA-Z]{2,7})"; // Email Address 1 string re2 = "(.)"; // Any Single Character 1 string re3 = "((?:[a-z][a-z]*[0-9]+[a-z0-9]*))"; // Alphanum 1 string re4 = "(\\s+)"; // White Space 1
Regex r = new Regex(re1 + re2 + re3 + re4, RegexOptions.IgnoreCase | RegexOptions.Singleline); foreach (Match ItemMatch in r.Matches(txt)) { Console.WriteLine(ItemMatch); } Console.ReadLine(); } } }
![[Image: GvjPoPu.png]](https://i.imgur.com/GvjPoPu.png) ]
Assert failure(PID 10704 [0x000029d0], Thread: 10960 [0x2ad0]): pBuffer != NULL
Jan 1, 2019 03:23 PM
(This post was last modified: Jan 1, 2019 03:25 PM by DBots.)
According to the pattern that I see, you could search for "- Login: " in each line and work with that.
Here is a VB sample, find a converter if you can't read it
https://pastebin.com/FFgZtNkW
Result:
Jan 1, 2019 03:44 PM
(This post was last modified: Jan 1, 2019 03:51 PM by gigajew.)
If you still use regular expression, this is all you need:
Code Login:\s(.*?):(.*?)$
And here's an example code without regex:
|