My apologies if i have not been able to explain this in easy terms.
What i have is: A syslistview to get data from. Column1 data needs to be modified.
What we know is: the 3 characters we are looking for will always be the rightmost of text in column1, if they are present at all.(Those 3 characters are "FUT")
What is needed is: If "FUT" is found in column1 row1, then TRIM 8 characters from right. (includes trimming off of "FUT" as well). Then move down and repeat till last value of that column.
Below is the code developed by me till now. Need help in removing "xxxxxFUT" if "FUT" found :
#Persistent
#Include %A_ScriptDir%
#SingleInstance force
#NoEnv
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, 1
SetKeyDelay, 150, 150, Play
SetControlDelay,0
iffut:="FUT"
SetTimer,datos,10
return
datos:
IfWinExist,DataTable ahk_class #32770
{
WinGetTitle,winname,DataTable
StringTrimLeft,winname,winname,11
IfInString,winname,%iffut%
{
StringTrimRight,winname,winname,8
}
ControlGet,dato,List,,SysListView321,DataTable
StringReplace, dato, dato, %A_Tab%, `,, All
StringReplace, dato, dato, %A_Space%, `,, All
IfInString,dato,%iffut%
{
;MsgBox,there
StringReplace, dato, dato, .{5}FUT, , All
}
FormatTime, mydttm, , ddMMyy_HHmmss
FileAppend,%dato%,%winname%_%mydttm%.txt
return
}
Edit:
A better answer is
dato := RegExReplace(dato, ".{5}FUT", "").
No need to check if it is in the string, as it will do nothing if it isn't. – Provided by --> Elliot DeNolf
Got an answer somewhere else so posting it here as well.
String-pattern is created and then using regexreplace to remove all such strings.
Below is the code to achieve that:
regex_patten = \d{2}[a-zA-Z]{3}FUT
if RegExMatch(string, regex_patten)
newstring := RegExReplace(string, regex_patten, "")
msgbox % "old string:`n`n" string "`n`nnew string`n`n" newstring