JohnBailey Posted June 19, 2007 Share Posted June 19, 2007 (edited) How do I search for text in a particular position in a row. I know FileRead will get the row but how do I say search after x amount of characters. For instance, 06/15/2007 06/18/2007 Cumulative That is the text (Row 9) in my file I want to search. However, I need to check that second date against the current date. Both dates change so I can't use _StringBetween. I know the string I want starts at 109 and ends at 119 Edited June 19, 2007 by JohnBailey A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted June 19, 2007 Author Share Posted June 19, 2007 The following seems to be my answer, but this method is limited and seems inefficient FileOpen($filetoRead,0) ConsoleWrite('Line: '&FileReadLine($filetoRead,9)&@CRLF) Local $StringBetween = _StringBetween (FileReadLine($filetoRead,9),' ',' C') Local $answerp1 = StringTrimLeft(FileReadLine($filetoRead,9),108) Local $answerp2 = StringTrimRight($answerp1,26) ConsoleWrite('Amount: '&StringLen(' Cumulative')&@CRLF) ConsoleWrite('Check Date: '&$answerp2&@CRLF) A decision is a powerful thing Link to comment Share on other sites More sharing options...
/dev/null Posted June 19, 2007 Share Posted June 19, 2007 How do I search for text in a particular position in a row. I know FileRead will get the row but how do I say search after x amount of characters. For instance, 06/15/2007 06/18/2007 Cumulative That is the text (Row 9) in my file I want to search. However, I need to check that second date against the current date. Both dates change so I can't use _StringBetween. I know the string I want starts at 109 and ends at 119 #include <array.au3> $string = " 06/15/2007 06/18/2007 Cumulative " $pattern = '^\s*([^\s]*)\s*([^\s]*)\s*([^\s]*)\s*$' $values = StringRegExp($string,$pattern,1) _ArrayDisplay($values) Then search in the row you need. __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
JohnBailey Posted June 19, 2007 Author Share Posted June 19, 2007 (edited) WOW!!!! Thank you!!!! WAAAAAAAY COOL I don't really understand what the below means though. I'm reading the Manual, but I'm still not understanding. I don't want to regurgitate this info every time. $pattern = '^\s*([^\s]*)\s*([^\s]*)\s*([^\s]*)\s*$' EDIT: wording Edited June 19, 2007 by JohnBailey A decision is a powerful thing Link to comment Share on other sites More sharing options...
/dev/null Posted June 19, 2007 Share Posted June 19, 2007 (edited) WOW!!!! Thank you!!!! WAAAAAAAY COOL I don't really understand what the below means though. I'm reading the Manual, but I'm still not understanding. I don't want to regurgitate this info every time. $pattern = '^\s*([^\s]*)\s*([^\s]*)\s*([^\s]*)\s*$' EDIT: wording it's a regular expression. See here: http://www.regular-expressions.info/tutorial.html The expression '^\s*([^\s]*)\s*([^\s]*)\s*([^\s]*)\s*$' means: ^\s* = any whitespace (space, tabs, etc.) ([^\s]*) = any NON-whitespace AND remember etc. Edited June 19, 2007 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
JohnBailey Posted June 19, 2007 Author Share Posted June 19, 2007 sweeet site and thanks for the explanation! This is so helpful! My previous methods totally sucked A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted June 19, 2007 Author Share Posted June 19, 2007 That is a really great site! I'm passing it on to some buddies of mine that will probably appreciate it and use the info right away! A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted June 20, 2007 Author Share Posted June 20, 2007 Ok, I'm not getting this... Here's what I'm trying to break into four separate rows BILL WILDS 9,700.48 610,633.74 1.11 Doing the following only gets me "BILL" in the array[0]. Why? Local $StringtoBreak = $fileArray[12] ConsoleWrite('String to Break: '&$StringtoBreak&@CRLF) Local $pattern = '^\s*([^\s]*[^\s]*)' Local $BroketoColumns = StringRegExp($StringtoBreak,$pattern,1) If @error Then MsgBox(0,'Error with StringRegExp',@error&' '&@extended) _ArrayDisplay($BroketoColumns) Additionally, I can't seem to find what $ means A decision is a powerful thing Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 20, 2007 Moderators Share Posted June 20, 2007 Ok, I'm not getting this... Here's what I'm trying to break into four separate rows BILL WILDS 9,700.48 610,633.74 1.11 Doing the following only gets me "BILL" in the array[0]. Why? c2--><!--TG9jYWwgJiMwMzY7U3RyaW5ndG9CcmVhayA9ICYjMDM2O2ZpbGVBcnJheVsxMl0KQ29uc29sZVdyaXRlKCYjMzk7U3RyaW5nIHRv IEJyZWFrOiAgICYjMzk7JmFtcDsmIzAzNjtTdHJpbmd0b0JyZWFrJmFtcDtAQ1JMRikKTG9jYWwgJiMwMzY7cGF0dGVybiA9ICYj Mzk7XiYjMDkyO3MqKFteJiMwOTI7c10qW14mIzA5MjtzXSopJiMzOTsKTG9jYWwgJiMwMzY7QnJva2V0b0NvbHVtbnMgPSBTdHJp bmdSZWdFeHAoJiMwMzY7U3RyaW5ndG9CcmVhaywmIzAzNjtwYXR0ZXJuLDEpCklmIEBlcnJvciBUaGVuIE1zZ0JveCgwLCYjMzk7 RXJyb3Igd2l0aCBTdHJpbmdSZWdFeHAmIzM5OyxAZXJyb3ImYW1wOyYjMzk7ICAgJiMzOTsmYW1wO0BleHRlbmRlZCkKCQpfQXJy YXlEaXNwbGF5KCYjMDM2O0Jyb2tldG9Db2x1bW5zKQ==--><!--eg Additionally, I can't seem to find what $ means$ = end of string. Do you have a file example, something that shows a whole list of information? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 20, 2007 Moderators Share Posted June 20, 2007 (edited) An example of me being lazy #include <array.au3> $sString = " BILL WILDS 9,700.48 610,633.74 1.11" $sPattern = '(?s)(?i)\s+(\w+\s\w*|.*?)(?m:$|\s)' $aArray = StringRegExp($sString, $sPattern, 3) _ArrayDisplay($aArray) Edit: Ugh... what the hell is wrong with the code after editing or comments? Edited June 20, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
FreeFry Posted June 20, 2007 Share Posted June 20, 2007 (edited) Maybe you should try out StringTrimLeft/StringTrimRight, StringInStr, StringLeft/StringRight etc. functions and see if you can work something out like that(getting a hold of using strings is a good knowledge to have imo. ) Edited June 20, 2007 by FreeFry Link to comment Share on other sites More sharing options...
FreeFry Posted June 20, 2007 Share Posted June 20, 2007 Ugh... what the hell is wrong with the code after editing or comments?Yeah, the code looks almost like if it have been encrypted or something :| // offtopic Link to comment Share on other sites More sharing options...
/dev/null Posted June 20, 2007 Share Posted June 20, 2007 An example of me being lazy c2--><!--I2luY2x1ZGUgJmx0O2FycmF5LmF1MyZndDsKCiYjMDM2O3NTdHJpbmcgPSAmcXVvdDsgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICBCSUxMIFdJTERTICAgICAgICAgICAgICAgICAgICAgICAgOSw3MDAuNDggICAgICAgICAgICAgICA2MTAsNjMz Ljc0ICAgICAgICAgICAgICAgICAgICAgIDEuMTEmcXVvdDsKJiMwMzY7c1BhdHRlcm4gPSAmIzM5Oyg/cykoP2kpJiMwOTI7cysoJiMwOTI7dysmIzA5MjtzJiMwOTI7dyp8Lio/KSg/bTomIzAzNjt8JiMwOTI7cykmIzM5OwomIzAzNjthQXJyYXkgPSBTdHJpbmdSZWdFeHAoJiMwMzY7c1N0cmluZywgJiMwMzY7c1Bh dHRlcm4sIDMpCl9BcnJheURpc3BsYXkoJiMwMzY7YUFycmF5KQ==--><!--eg Edit: Ugh... what the hell is wrong with the code after editing or comments? seems to be a bug after the forum software upgrade. __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
JohnBailey Posted June 20, 2007 Author Share Posted June 20, 2007 Freefly, I originally was achieving my goal using the String functions you mentioned. However, doing so isn't dynamic (at least how I was doing it).Smoke_N, that's awesome. I'm still not entirely understanding the differences between all the symbols. I went to http://e-texteditor.com/blog/2007/regular_...ssions_tutorial but I'm still confused. I'm not really picking this up well at all. A decision is a powerful thing Link to comment Share on other sites More sharing options...
FreeFry Posted June 20, 2007 Share Posted June 20, 2007 (edited) seems to be a bug after the forum software upgrade.Let's bow down to Jon, and pray for him to fix it! Freefly, I originally was achieving my goal using the String functions you mentioned. However, doing so isn't dynamic (at least how I was doing it).Hmm, well I think you probably could make it dynamic, you just have to make it detect what kind of content the row contains. Or try to understand the RegExp stuffEdit:damnit my name is FreeFry xD Edited June 20, 2007 by FreeFry Link to comment Share on other sites More sharing options...
JohnBailey Posted June 20, 2007 Author Share Posted June 20, 2007 Let's bow down to Jon, and pray for him to fix it! Hmm, well I think you probably could make it dynamic, you just have to make it detect what kind of content the row contains. Or try to understand the RegExp stuffhuh? A decision is a powerful thing Link to comment Share on other sites More sharing options...
FreeFry Posted June 20, 2007 Share Posted June 20, 2007 (edited) Hmm, I was under the influence that " 06/15/2007 06/18/2007 Cumulative"and" BILL WILDS 9,700.48 610,633.74 1.11"was two different rows, and that you might somehow identify what type of "data" the row contains, and make a dynamic, yet in a way, static detection system, and that way get what you want from the rowsEdit:whops Edited June 20, 2007 by FreeFry Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 20, 2007 Moderators Share Posted June 20, 2007 Hmm, I was under the influence that " 06/15/2007 06/18/2007 Cumulative"and" BILL WILDS 9,700.48 610,633.74 1.11"was two different rows, and that you might somehow what type of "data" the row contains, and make a dynamic, yet in a way, static detection system, and that way get what you want from the rowsAre you sure that influence didn't stem over till the 20th? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
JohnBailey Posted June 20, 2007 Author Share Posted June 20, 2007 Hmm, I was under the influence that " 06/15/2007 06/18/2007 Cumulative"and" BILL WILDS 9,700.48 610,633.74 1.11"was two different rows, and that you might somehow what type of "data" the row contains, and make a dynamic, yet in a way, static detection system, and that way get what you want from the rowsyeah I am just trying to make a var for each "column" in each row, so I can use it. I was confused on what you meant by the Jon stuff. A decision is a powerful thing Link to comment Share on other sites More sharing options...
FreeFry Posted June 20, 2007 Share Posted June 20, 2007 Are you sure that influence didn't stem over till the 20th?woot yeah I am just trying to make a var for each "column" in each row, so I can use it. I was confused on what you meant by the Jon stuff.Yes, sorry, I posted right after your post, I was responding to Sm0ke_N's post about the forum bug, I edited my post to make it a little clearer. I'm a little bit tired now doh xD 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