RyukShini Posted June 24, 2016 Posted June 24, 2016 #Include <file.au3> #Include <Array.au3> Local $nobrainArray $var = _FileReadToArray("example.txt", $nobrainArray) $split = StringSplit($var, ":"); split by colon? _ArrayDisplay($split) Its getting later and I am getting more and more tired so I think I should go to bed and give this another look tmr. but if someone could help me i'd be grateful! randomfirstname:randomlastname\nrandomfirstname:randomlastname\nrandomfirstname:randomlastname\nrandomfirstname:randomlastname\nrandomfirstname:randomlastname\nrandomfirstname:randomlastname\nrandomfirstname:randomlastname\nrandomfirstname:randomlastname\nrandomfirstname:randomlastname\n----------------------------------------------------------------------\n\nThe topic can be found here:\nhttps://www.websitehere.com\n\n\nYou can unsubscribe at any time here: https://www.websitehere.com/unsubscribe/Zm9ydW1zO2ZvcnVtczs0MzszOTc0MTA7Mzk3NDEwO25pa29sYXppbmRvQGdtYWlsLmNvbQ,,/\n\nIf you are not following any forums and wish to stop receiving notifications, uncheck the setting\n\"Send me news and information\" found in \'My Settings\' under \'Notification Options\'.\n',545627,'followed_forums','https://www.websitehere.com/topic/','forums','forums',43,'4745c9f0607baec3e8bc38f47d07f9bd'),(622776,49813,1457299052,1,'<a href=\'https://www.websitehere.com/!545627\'>Antepliemmo</a> posted topic <a href=\'https://www.websitehere.com\'>\n\n----------------------------------------------------------------------\n As you can see this is very messy! There is random first names and last names everywhere and then there is a lot of junk.... I am extracting all the names/last names for a buddy, but I just can't seem to figure it out. Any help is appreciated, I'll keep working on this tomorrow again wish a fresh mindset! Regards Ryuk
mikell Posted June 24, 2016 Posted June 24, 2016 Something like this... maybe... It uses your sample text above so it's mainly for the concept #Include <Array.au3> $var = StringReplace(FileRead("example.txt"), "\n", @crlf) $res = StringRegExp($var, '(\w+:\w+)', 3) _ArrayDisplay($res)
kylomas Posted June 24, 2016 Posted June 24, 2016 RyukShini, Try this... #include <array.au3> local $aRSLT = stringregexp(fileread(@desktopdir & '\test10.txt'),'(?:\\n)?(\w+:\w+)(?:\\n)?',3) _arraydisplay($aRSLT) kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
RyukShini Posted June 24, 2016 Author Posted June 24, 2016 10 minutes ago, kylomas said: RyukShini, Try this... #include <array.au3> local $aRSLT = stringregexp(fileread(@desktopdir & '\test10.txt'),'(?:\\n)?(\w+:\w+)(?:\\n)?',3) _arraydisplay($aRSLT) kylomas You are just amazing man! Can you explain this: '(?:\\n)?(\w+:\w+)(?:\\n)?' Thanks in advance.
Moderators JLogan3o13 Posted June 24, 2016 Moderators Posted June 24, 2016 Maybe look in the help file, under StringRegExp, to learn on your own? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Malkey Posted June 25, 2016 Posted June 25, 2016 Another example. #include <Array.au3> ;ConsoleWrite(StringRegExpReplace(FileRead(@ScriptName), "(?s)^.*#cs\v*|\v*#ce.*$", "") & @LF) ;$var = StringReplace(FileRead("example.txt"), "\n", @crlf) ; For use if "example.txt" file is available. ; or $var = StringRegExpReplace(FileRead(@ScriptName), "(?s)^.*#cs\v*|\v*#ce.*$", "") ; For use in this example only where data is between #cs and #ce $res = StringRegExp($var, '(?i)([a-z\h\-\.]+:[a-z\h\-\.]+)\\n', 3) _ArrayDisplay($res) #cs randomfirstnameA:random de lastnameA\nrandomfirstnameB:randomlast-nameB\nrandomfirstnameC:randomlastnameC\nrandomBillie-JoD:randomlastnameD\nrandomfirstnameE:random lastnameE\nrandomfirstnameF:randomlastnameF Jr.\nrandomfirstnameG:randomlastnameG\nrandomfirstnameH:randomlastnameH\nrandomfirstnameI:randomlastnameI\n----------------------------------------------------------------------\n\nThe topic can be found here:\nhttps://www.websitehere.com\n\n\nYou can unsubscribe at any time here: https://www.websitehere.com/unsubscribe/Zm9ydW1zO2ZvcnVtczs0MzszOTc0MTA7Mzk3NDEwO25pa29sYXppbmRvQGdtYWlsLmNvbQ,,/\n\nIf you are not following any forums and wish to stop receiving notifications, uncheck the setting\n\"Send me news and information\" found in \'My Settings\' under \'Notification Options\'.\n',545627,'followed_forums','https://www.websitehere.com/topic/','forums','forums',43,'4745c9f0607baec3e8bc38f47d07f9bd'),(622776,49813,1457299052,1,'<a href=\'https://www.websitehere.com/!545627\'>Antepliemmo</a> posted topic <a href=\'https://www.websitehere.com\'>\n\n----------------------------------------------------------------------\n #ce
RyukShini Posted June 25, 2016 Author Posted June 25, 2016 11 hours ago, JLogan3o13 said: Maybe look in the help file, under StringRegExp, to learn on your own? Doing that now, sorry that was only my laziness talking! Thanks
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now