StringRegExpReplace - Simple Replace

4 posts in this topic

SkellySoul 3

It's 5:30 AM and been sitting here staring at the help file but it looks like an alien language to me.

I have the following example strings

[8]Bird
[9]Cat
[10]Dog

What I want is

Bird
Cat
Dog

Now a easy solution would be to just trim it to the left by 3, however there are cases when it could be 4 (example Dog being [10]), so I figured StringRegExpReplace() is what I am going to have to use unless there is a easier/better method.

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)

Similar Content

Hello
I am relatively new to the world of Microsoft Office and the Excel UDF.
I am trying to loop through every row in a spreadsheet and get the text/values from each column in the given row... so far I have looked into the Help file for the Excel UDF and the wiki page for Excel UDF but I have no idea about how this is done ... This is all I have in my script:
Global $oExcel = _Excel_Open(False, False, False, False, True)
Global Const $sSpreadsheet = @ScriptDir & '\data.xlsx'
Global $oSpreadsheet = _Excel_BookOpen($oExcel, $sSpreadsheet, True, False)
; ...
I am placing my bet on the _Excel_Range functions... especially _Excel_RangeRead. I don't know how $vRange works so I would be glad if someone can point me in the right direction . What I would ideally like is to get all of the contents of the spreadsheet (it's just a normal text one) in a 2D array.
Thanks in Advance!

So I ran into this crazy "program" that cant be uninstalled via WMI, MSIExec, etc.
The only way to uninstall it was from Add/Remove programs manually... Or I found if you find it in the registry under HKCU and run the uninstall string, it will also uninstall.
However the string in the registry cant be run directly in a cmd window because of the format errors.
It has spaces without quotations, it has invalid characters, etc, etc
I know things run different when executed in the registry, so maybe there is a way I can run the regsitry key just like how the system does? If so chime in.
Otherwise I did this a crude way using several stringregexpreplace() functions and have it working.
The solution feels so barbaric and crude that I wanted to post it so some of you guys better than me can clean up the code, maybe offer alternative ways to do it, or reduce the number of times I process the string.
Here is the string right out of the registry:
c:\Program Files\Common Files\Microsoft Shared\VSTO\10.0\VSTOInstaller.exe /Uninstall file:///C:/Users/it022565/AppData/Local/Temp/OOBAXTOWordAddIn/ApplicationXtender.AXTO.Word.vsto
Here is my cave man scripting to turn this into a run able string.

i used the script from @mikell to build this func:
Func _Translate($sFrom, $from, $to)
;thanks to mikell (autoitscript.com)
;https://www.autoitscript.com/forum/topic/182893-prompt-me-how-to-see-the-text-in-the-translation-boxhttpstranslategooglecom/?do=findComment&comment=1313423
Local $url = "https://translate.googleapis.com/translate_a/single?client=gtx"
$url &= "&sl=" & $from & "&tl=" & $to & "&dt=t&q=" & $sFrom
Local $oHTTP = ObjCreate("Microsoft.XMLHTTP")
$oHTTP.Open("POST", $url, False)
$oHTTP.Send()
Local $sData = $oHTTP.ResponseText
$sData = StringRegExpReplace($sData, '.*?\["(.*?)"[^\[]*', "$1" & @CRLF)
Return $sData
EndFunc ;==>_Translate
when i call this func with:
$sText='AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying "runtimes" required!'
MsgBox(64,'',_Translate($sText,'en','de'))
nearly all is seeing here:

only the "!" is wrong "\" but when using 'auto' instead of 'en' the result is:

2 lines are appended. So my question is, is it possible to extend the pattern (i never worked with regex) and in best case setting @extended with the detected language?
@Trong: as you can see yet i am returning translated text and don't use GuiCtrlSetData to assign it to a EditBox.