Realm Posted May 27, 2010 Share Posted May 27, 2010 (edited) I have been playing with this for 4 hours now, so sorry to bug over something that is probably minor. I'm pulling this text off a website via _IEBodyReadText, there is much more text, but this is a clip as it appears, of the area i need the string from Who would you like to help? name1, name2, Name3, 4name, 5name, NaME6, na7me LostinTranslation What I need is: name1, name2, Name3, 4name, 5name, NaME6, na7me This is my StringRegExp, as I thought it would work, but noob as I am, I'm hoping the problem is here: $rhelpers = StringRegExp($rText, 'help?(.*[A-z0-9\,]?)LostInTranslation', 1, 1) Thanks ahead of time for any help! edit: $rText is the string pulled from _IEBodyReadText Edited May 28, 2010 by Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
UEZ Posted May 27, 2010 Share Posted May 27, 2010 If the text above name1, name2, ... is everytime the same you can try this: $String = "Who would you like to help?" & @CRLF & _ "name1, name2, Name3, 4name, 5name, NaME6, na7me" & @CRLF & @CRLF & _ "LostinTranslation" $aRegExp = StringRegExp($String, "Who would you like to help\?\r\n(.*)\r\n*.", 1) If IsArray($aRegExp) Then ConsoleWrite($aRegExp[0] & @CRLF) BR, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
GEOSoft Posted May 27, 2010 Share Posted May 27, 2010 Lets make this multiple choice; #include<array.au3> $aRegExp = StringRegExp($String, "(\w+?)(?:,|\z|\v)+", 3) If NOT @Error Then GUICtrlSetData($hSomeComboBox, _ArrayToString($aRegExp)) EndIf George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Realm Posted May 27, 2010 Author Share Posted May 27, 2010 Thanks to both of your suggestions. @UEZ, your example did not work for some reason, don't know if there is not a cursor return after 'help?' or what it had an error on, I also tried something similar earlier with fail. @GEOSoft, Your example did work, however it pulled a bunch of other arrays from the text as well, some I don't understand why, like the links at the bottom of the web page, they are not delemited by commas like the names are. So is there a way to just obtain the text from between 'help? (pull names) LostInTranslation' as a solid string, than I could split the string into arrays later? My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
JohnOne Posted May 27, 2010 Share Posted May 27, 2010 Im going with _StringBetween() AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
sahsanu Posted May 27, 2010 Share Posted May 27, 2010 It is a dirty code but it works for me #include <array.au3> $String = "Who would you like to help?" & @CRLF & _ "name1, name2, Name3, 4name, 5name, NaME6, na7me" & @CRLF & @CRLF & _ "LostinTranslation" $aRegExp = StringRegExpReplace($String, "(.*[\r\n]{1,})(.*,.*[\r\n]{1,})(.*)", "$2") $aRegExp = StringRegExp($aRegExp, "(\w+)[,|\s]",3) _ArrayDisplay($aRegExp) Link to comment Share on other sites More sharing options...
GEOSoft Posted May 27, 2010 Share Posted May 27, 2010 (edited) $sStr = StringRegExpReplace(FileRead("Somefile.txt"), "(?i)(?s).*Who would you like to help\?\v+(.+?)\v+lostintranslation.*", "$1") If thi returns the proper string then you can probably just stringspli on the commas to get the array or continue using the SRE I gave you earlier. Edited May 27, 2010 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Realm Posted May 28, 2010 Author Share Posted May 28, 2010 You guys all Rock!!! So many examples, most are great! sorry I did not see most of them before coming to a final solution! @JohnOne, Thanks StringBetween was exactly what I needed, though I had a few minor obstacles like spaces before each name, and a few Carriage Returns, but with a little work and now it delivers exactly what I need, Thanks again to everyone and the help, even though I may not have used some of your examples, I sure have gained some well needed knowledge from them. I have been trying to avoid using StringRegExp for so long because it has been very confusing to me, but today your examples have enlightened me on some uses and how they work. Thanks again! ...and before I go, this is what I finally ended up with: $rText = "Who would you like to help?" & @CRLF & _ "name1, name2, Name3, 4name, 5name, NaME6, na7me" & @CRLF & @CRLF & _ "LostinTranslation" $rArray=_StringBetween($rText, 'help?' & @crlf, @crlf & @crlf & 'LostinTranslation') $rhelpers=StringSplit(StringReplace($rArray[0], " ", ""), ",") _ArrayDisplay($rhelpers, 'Default Search') My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
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