Jump to content

Replace in array @CRLF


Go to solution Solved by Jury,

Recommended Posts

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

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

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

(?-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 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 here
RegExp tutorial: enough to get started
PCRE 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

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.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...