Jump to content

Can this be done in AutoIt?


 Share

Recommended Posts

I was talking to an excel m8 the other night and i assumed this task could be done in excel but it appears not as simple as i thought it was so i thought id ask you guys.

I have a text file in this format and i will recieve more of them so it will be an ongoing thing

:: Dub.com Toolbar
start /wait msiexec /qn /norestart /x {8e5025c2-8ea3-430d-80b8-a14151068a6d}

:: 1k.FM Toolbar
start /wait msiexec /qn /norestart /x {3a9262ef-45b5-46fc-b460-7053539c9176}

So i use replace in notepad to change it like this

:: Dub.com Toolbar
'|{8e5025c2-8ea3-430d-80b8-a14151068a6d}' & _  ;  
:: 1k.FM Toolbar
'|{3a9262ef-45b5-46fc-b460-7053539c9176}' & _  ;

Labourious but simple enough but here's the tricky bit

I need to add the titles of the uninstaller at the end of the files like this example

'|{8e5025c2-8ea3-430d-80b8-a14151068a6d}' & _  ;  Dub.com Toolbar
'|{3a9262ef-45b5-46fc-b460-7053539c9176}' & _  ;  1k.FM Toolbar

So i can copy it into my script and the array will work and there is the problem how to automate that part?

Also if a uninstaller has multiple entries like this

'|{8e5025c2-8ea3-430d-80b8-a14151068a6d}' & _  ;  Dub.com Toolbar
'|{A957F04C-49F4-4375-8C8A-D04B769EFE47}' & _  ;  
'|{1bc82e67-afbc-434a-aae9-eb0776452f05}' & _  ;  
'|{4D84CC03-383C-4BB1-A485-B263A03E9FF1}' & _  ;  
'|{3a9262ef-45b5-46fc-b460-7053539c9176}' & _  ;  1k.FM Toolbar

I only need it to move the title to the first entry not the subsequent ones

So any thoughts on how to solve this?

Link to comment
Share on other sites

Regular expression for example could be used https://regex101.com/r/wW9fX3/1, though you will need to piece it together using that regexp I have provided (based on the info above) and StringRegExp(). I would, but I think it's good practice for you to try it yourself, as I take it that this is for your job as well as the help file being pretty informative.

Hint: For simplicity _FileReadToArray() and then regexp every third line or something along those lines, so you could use Mod($i, 3) or something similar.

 

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Just as note:   https://regex101.com/r/wW9fX3/1

closing paranthesis ....

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

@mikell : I think it looks like this :

:: Dub.com Toolbar
start /wait msiexec /qn /norestart /x {8e5025c2-8ea3-430d-80b8-a14151068a6d}
start /wait msiexec /qn /norestart /x {A957F04C-49F4-4375-8C8A-D04B769EFE47}
start /wait msiexec /qn /norestart /x {1bc82e67-afbc-434a-aae9-eb0776452f05}
start /wait msiexec /qn /norestart /x {4D84CC03-383C-4BB1-A485-B263A03E9FF1}


:: 1k.FM Toolbar
start /wait msiexec /qn /norestart /x {3a9262ef-45b5-46fc-b460-7053539c9176}

 

Link to comment
Share on other sites

I am no regex master but this is very close.

I took the context of your file before you did any modification and created this script.

#Include <StringConstants.au3>

$sFile = FileRead(@ScriptDir & "\doc.txt")
$sFile = StringStripWS($sFile, $STR_STRIPALL)
$sFile = StringRegExpReplace($sFile, "(?i)::(.+?ToolBar).+?({.+?})", "'|$2' & _  ; $1" & @CRLF)
MsgBox(0, "", $sFile)

 

doc.txt

Capture.JPG

Edited by ViciousXUSMC
Link to comment
Share on other sites

I can see this thread escalating into multiple solutions and getting no where close to what is required. A lot more details should be provided before any real solution is provided, hence why I have only shown @Chimaera where to look and for them to continue to meet their requirements.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Id say my result looks like what he wants :) just what are the chances everything's ends in "toolbar" and what happens if there is more than one uninstall string (just repeat the last capture group).

But no harm in chiming in with a (partial) solution gives us all a chance to learn bits and pieces from each other.

Link to comment
Share on other sites

Id say my result looks like what he wants :) 

I don't think so, you missed the part about multiple entries.

But no harm in chiming in with a (partial) solution gives us all a chance to learn bits and pieces from each other.

Well I have seen it happen too often around here with these regular expression threads, that too much white noise leads to very little in the way of learning. A parsing related question such as this, should have a thorough description of the expected input and output, as well as all the possible scenarios in between.

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Assuming the 'Toolbar' is only in the example, this should work generically

$txt = FileRead("1.txt")

$r1 = StringRegExpReplace(StringRegExpReplace($txt, '.*(\{.+\})', "'|$1' & _  ;"), '::\s*(.+\R)(.+)\R?', "$2   $1")
; optional, remove empty lines :
$r2 = StringRegExpReplace($r1, '(?m)^\s*\R?', "")

Msgbox(0,"", $r2)

Edit
Obviously - as said guinness rightly - this should work until a new and unexpected requirement occurs  :D

Edited by mikell
Link to comment
Share on other sites

@Guiness I agree more input is better for parsing.  

I like to throw what I know and see what sticks, often somebody can  use what I know and it may be the one piece they did not think of (often the inexperienced like myself are the ones that come up with some off the wall solution) most of what I have learned so far is from the back and forth in other threads where somebody had a "solution" and somebody pointed out why that was not the best solution and how this way works better.  

But I get your gist, esp with RegEx threads they are quite notorious around here :) I am glad I have hit a level that I can at least chim in a bit so people can continue to teach me.

Link to comment
Share on other sites

Assuming the 'Toolbar' is only in the example, this should work generically

$txt = FileRead("1.txt")

$r1 = StringRegExpReplace(StringRegExpReplace($txt, '.*(\{.+\})', "'|$1' & _  ;"), '::\s*(.+\R)(.+)\R?', "$2   $1")
; optional, remove empty lines :
$r2 = StringRegExpReplace($r1, '(?m)^\s*\R?', "")

Msgbox(0,"", $r2)

 

This example seems to work the best, but there's still some errors, ive got a few endings that are not the same so ill look into that and see what i can come up with.

Many thanks, at least its possible :)

I might try and build in the manual bits as well

Link to comment
Share on other sites

Well I have seen it happen too often around here with these regular expression threads, that too much white noise leads to very little in the way of learning. A parsing related question such as this, should have a thorough description of the expected input and output, as well as all the possible scenarios in between.

Two thoughts

A: i didn't know it was a regex question and ive never heard of parsing

B: I thought i gave a thorough explanation, maybe its the diff between programmers like yourself and hobby lads like me.

Intellectually I agree with your comment about white noise but i'm an adjuster i take what scraps i find around the forum and adjust them into something that's nasty and not good code but it works for the limited stuff i do. 99% of my stuff is read an array and run it against a cmd action. And i mostly reuse what i have

I try my best to write code properly (as i understand it) but it does get rained on when i post sometimes ;)

And i try not to ask to often as well because i dont want to rely on everyone here

I would imagine if i stop working in the pc shop i will prob stop coding as well, its a thing i do for a few hrs a week to try and make my life easier, i dont have the drive some of you lads have.

That said it doesn't mean i don't appreciate the help as many have been really kind in the years i have been here.

Link to comment
Share on other sites

A: i didn't know it was a regex question and ive never heard of parsing

B: I thought i gave a thorough explanation, maybe its the diff between programmers like yourself and hobby lads like me.

Parsing is quite a general term and something you should have come across over the years on the Forum. As for the "hobbyist" comment, I just don't see the relevancy nor should it be used as some excuse. I am a hobbyist as well!

As demonstrated already, you clearly have a specific set of rules for how your file is laid out that you would like to parse (read and translate into something different). Therefore it's best if you come up with all possible scenarios. Try and re-read your post and think ... "What would I need to know to help this user? Should they know about the alternative line endings? Would it help to have more examples? Maybe I should demonstrate an example of a file I would like to parse?" 

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

My regexes are infinitely better because of the regex gamesmanship exhibited by folks like JGunich and Mikell.  The desire to foolproof something against edgecases before the question is fully formed is part of the learning, you just learned something else instead.   Helping the OP in their efforts is secondary to getting all that shit on one line first.

I would attribute most of my success with Splunk and WQL directly to learning PCRE in this forum.  The ability to write good RegEx is as marketable as any other language, the enjoyment of it even moreso.  And I have found the best place to learn regex is not some other website, it is right here.   The user picks any regular expression or any string and says that, 'my regex is the best' or 'this cant be done' , and a lessonplan will be personalized.  For $0.

 

Wouldnt use it for this task tho, I would read the notepad into an array, and as long as those colons are reliable (I know mine isnt).  

#include<array.au3>

local $array[7]

$array[0]='::Dub.com Toolbar'
$array[1]='|{8e5025c2-8ea3-430d-80b8-a14151068a6d}'
$array[2]='|{A957F04C-49F4-4375-8C8A-D04B769EFE47}'
$array[3]='|{1bc82e67-afbc-434a-aae9-eb0776452f05}'
$array[4]='|{4D84CC03-383C-4BB1-A485-B263A03E9FF1}'
$array[5]='::1k.FM Toolbar'
$array[6]='|{3a9262ef-45b5-46fc-b460-7053539c9176}'

For $i = ubound($array) - 2 to 0 step - 1
    If stringleft($array[$i], 2) = "::" Then
        $array[$i + 1] = $array[$i + 1] & " ; " & $array[$i]
        _ArrayDelete($array , $i)
    EndIf
Next

_ArrayDisplay($array)

 

Edited by boththose
removed line continuations

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

boththose,
To fit the exact OP's requirements your code should be slightly modified

For $i = ubound($array) - 1 to 0 step - 1
    If stringleft($array[$i], 2) <> "::" Then
        $array[$i] = "'" & $array[$i] & "' & _  ; "
    Else
        $array[$i + 1] = $array[$i + 1] & StringTrimLeft($array[$i], 2)
        _ArrayDelete($array , $i)
    EndIf
Next

Anyway your array method is probably more versatile than a one-liner regex if some adaptations are further needed for 'particular' cases  :)

Edited by mikell
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...