Jewtus Posted April 25, 2014 Share Posted April 25, 2014 I'm having issues with an table that has a CRLF that I've grabbed using this command Local $oTable = _IETableGetCollection($oIE, 1) Local $aTableData = _IETableWriteToArray($oTable,True) column 3 has a CRLF and then the word NAME: for every row in the array. I'm trying to figure out how to replace any occurrences of @CRLF"NAME: " with the delimiter |. Any tips? Link to comment Share on other sites More sharing options...
JohnOne Posted April 25, 2014 Share Posted April 25, 2014 StringInStr StringReplace 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...
Jewtus Posted April 25, 2014 Author Share Posted April 25, 2014 I have been messing with those, but I don't think I understand completely how to execute them: _ArrayDisplay(StringReplace($aTableData,(@CRLF"Name :"),"|")) I've tried various iterations of this but every time the search string gives me an error when it gets to the @CRLF. If I put @CRLF in quotes, nothing shows up. Sorry if this is a dumb question. I'm just getting use to autoit, so some of the more complicated processes I'm trying to do get me very confused. I was using Powershell to do some of these (saved the array to a file and then ran the following powershell): $filepath = "C:\Automation\AutoIt\log\example.txt" $outfile = "C:\Automation\AutoIt\log\outfile.csv" (Get-Content $filepath -raw) | Foreach-Object {$_ -replace "Name: ", "`"|"` -replace "`n`"", ""` } | Set-Content $outfile but I was getting really inconsistent results with powershell. I was hoping I could do this whole thing with autoit. Link to comment Share on other sites More sharing options...
JohnOne Posted April 25, 2014 Share Posted April 25, 2014 You get this array right? Local $aTableData = _IETableWriteToArray($oTable,True) What does it look like? Create an example if you like or take a screenshot. Even just give a real text example of the exact contents of each element. 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...
Jewtus Posted April 25, 2014 Author Share Posted April 25, 2014 Link to comment Share on other sites More sharing options...
Jewtus Posted April 25, 2014 Author Share Posted April 25, 2014 I got an error For $j = 0 To UBound($aTableData),2) - 1 ^Error Illegal text at the end of statement (one statement per line) Link to comment Share on other sites More sharing options...
Jury Posted April 25, 2014 Share Posted April 25, 2014 (edited) oops I've made the correction now in my first reply - that line should read: For $j = 0 To UBound($aTableData[$i], 2) - 1 Edited April 25, 2014 by Jury Link to comment Share on other sites More sharing options...
Jewtus Posted April 25, 2014 Author Share Posted April 25, 2014 Error again For $j = 0 To UBound($aTableData[$i], 2) - 1 For $j = 0 To UBound(^ ERROR Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded Link to comment Share on other sites More sharing options...
sahsanu Posted April 25, 2014 Share Posted April 25, 2014 Error again For $j = 0 To UBound($aTableData[$i], 2) - 1 For $j = 0 To UBound(^ ERROR Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded That line should be: For $j = 0 To UBound($aTableData, 2) - 1 Cheers, sahsanu Jewtus 1 Link to comment Share on other sites More sharing options...
Jewtus Posted April 25, 2014 Author Share Posted April 25, 2014 That did it! Thanks! Jury, if you update it again I'll mark it as solved. Link to comment Share on other sites More sharing options...
Solution Jury Posted April 27, 2014 Solution Share Posted April 27, 2014 (edited) For $i = 0 To UBound($aTableData, 1) - 1 ; first dimension of array For $j = 0 to UBound($aTableData, 2) - 1 ; second dimension of array $aTableData[$i][$j] = StringRegExpReplace($aTableData[$i][$j], '(?-s)(?-i)\r?\n\s*NAME\s*:', '|') Next Next _ArrayDisplay($aTableData) Edited April 27, 2014 by Jury Link to comment Share on other sites More sharing options...
mikell Posted April 27, 2014 Share Posted April 27, 2014 What are (?-s) and (?-i) for ? Link to comment Share on other sites More sharing options...
jchd Posted April 27, 2014 Share Posted April 27, 2014 (edited) (?-s)(?-i) is the same as (?-is) and negates s and i options from there on. See options § in help. Pretty useless in this case since both are OFF by default. r?n can be replaced by R Edited April 27, 2014 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Jury Posted April 27, 2014 Share Posted April 27, 2014 Well, not completely useless if you are an old bloke and want constant reminding exactly what any given regEx is doing. But thanks for the explanation. Link to comment Share on other sites More sharing options...
mikell Posted April 27, 2014 Share Posted April 27, 2014 jc, my question was not specific enough... saying 'what is it for' I didn't ask for 'what does that mean' but : what is the use of this, except if used in the middle of a pattern to restore default(s) Link to comment Share on other sites More sharing options...
Jury Posted April 27, 2014 Share Posted April 27, 2014 These are regEx Modifiers I almost always use them to make my regular expressions more explicit and they enable one to modify what a given regEx is doing mid-expression e.g. ignoring the case of letters until you get to a certain point then turning case sensitivity on OR ignoring line returns/carriage returns until a certain point then recognising them again. As one of the worlds top experts - Jan Goyvaerts explains: (?i) Turn on case insensitivity for the remainder of the regular expression. (Older regex flavors may turn it on for the entire regex.) te(?i)st matches teST but not TEST. (?-i) Turn off case insensitivity for the remainder of the regular expression. (?i)te(?-i)st matches TEst but not TEST. (?s) Turn on "dot matches newline" for the remainder of the regular expression. (Older regex flavors may turn it on for the entire regex.) (?-s) Turn off "dot matches newline" for the remainder of the regular expression. (?m) Caret and dollar match after and before newlines for the remainder of the regular expression. (Older regex flavors may apply this to the entire regex.) (?-m) Caret and dollar only match at the start and end of the string for the remainder of the regular expression. (?x) Turn on free-spacing mode to ignore whitespace between regex tokens, and allow # comments. (?-x) Turn off free-spacing mode. (?i-sm) Turns on the options "i" and "m", and turns off "s" for the remainder of the regular expression. (Older regex flavors may apply this to the entire regex.) (?i-sm:regex) Matches the regex inside the span with the options "i" and "m" turned on, and "s" turned off. Jewtus 1 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