Opened 13 years ago
Last modified 2 years ago
#2370 assigned Feature Request
StringReplace & StringRegExpReplace Add Offset\The starting position of the search
| Reported by: | anonymous | Owned by: | Jon |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | Severity: | None | |
| Keywords: | Cc: |
Description
would be very useful to add the "Offset\The starting position of the search" in StringReplace\StringRegExpReplace to work much more faster with strings
it seems that in xxx works really well and quickly, instead ddd does not work well in almost as if it does not work at all
Local $sFileData, $iString, $iTimerDiff $sFileData = FileRead(@DesktopDir& "\test.ini") ; test.ini = 10 Mb - includes inside, the string TestXXXX $iTimerDiff = TimerInit() $iString = StringInStr($sFileData, "TestXXXX", 1, 1, 2767600) $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite($iString & " - " & $iTimerDiff & @LF) $iTimerDiff = TimerInit() $iString = StringRegExp($sFileData, "TestXXXX") $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite($iString & " - " & $iTimerDiff & @LF) $iTimerDiff = TimerInit() $iString = StringRegExp($sFileData, "TestXXXX", 0, 2767600) $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite($iString & " - " & $iTimerDiff & @LF) 2767692 - 0.00829366853445348 1 - 34.3946332855723 1 - 29.7493890330846
however looking at the speed of StringInStr, and also have this option in StringReplace\StringRegExpReplace would be really helpful
Sorry for my english
Ciao.
Attachments (0)
Change History (16)
comment:1 by , 13 years ago
| Version: | 3.3.8.1 |
|---|
comment:2 by , 13 years ago
sorry, post by mistake
it seems that in StringInStr works really well and quickly, instead StringRegExp does not work well in almost as if it does not work at all
Local $sFileData, $iString, $iTimerDiff $sFileData = FileRead(@DesktopDir& "\test.ini") ; test.ini = 10 Mb - includes inside, the string TestXXXX $iTimerDiff = TimerInit() $iString = StringInStr($sFileData, "TestXXXX", 1, 1, 2767600) $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite($iString & " - " & $iTimerDiff & @LF) $iTimerDiff = TimerInit() $iString = StringRegExp($sFileData, "TestXXXX") $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite($iString & " - " & $iTimerDiff & @LF) $iTimerDiff = TimerInit() $iString = StringRegExp($sFileData, "TestXXXX", 0, 2767600) $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite($iString & " - " & $iTimerDiff & @LF) 2767692 - 0.00829366853445348 1 - 34.3946332855723 1 - 29.7493890330846
Ciao.
comment:3 by , 13 years ago
DXRW4E, are you using the latest beta? The regex compiler that AutoIt uses has been updated. Can you give that a go please?
comment:4 by , 13 years ago
Yes, I always use the latest Beta, where I noticed that StringRegExpReplace has been improved a lot about the speed in the Case-sensitivity Mod, however have a flag "Offset\The starting position of the search" in StringReplace or in StringRegExpReplace,
as in StringInStr and StringMid that working really fast, would be really helpful
Ciao.
comment:5 by , 13 years ago
Local $sFileData, $iString, $iTimerDiff $sFileData = FileRead(@DesktopDir& "\fff.inf") ; test.ini = 11 Mb - includes inside, the string TestXXXX $iTimerDiff = TimerInit() $iString = StringInStr($sFileData, "TestXXXX", 1, 1, 7188000) $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite($iString & " - " & $iTimerDiff & @LF) $iTimerDiff = TimerInit() $iString = StringRegExp($sFileData, "TestXXXX") $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite($iString & " - " & $iTimerDiff & @LF) $iTimerDiff = TimerInit() $iString = StringRegExp($sFileData, "TestXXXX", 0, 7188000) $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite($iString & " - " & $iTimerDiff & @LF) ;~ >Running:(3.3.9.15):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "C:\Users\DXRW4E\Desktop\New AutoIt v3 Script (Beta).au3" ;~ --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop ;~ 7188325 - 0.0319898769811509 ;~ 1 - 37.974748533896 ;~ 1 - 28.9295120832874 ;~ +>08:32:23 AutoIt3.exe ended.rc:0 ;~ >Running:(3.3.8.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\DXRW4E\Desktop\New AutoIt v3 Script (Beta).au3" ;~ --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop ;~ 7188325 - 0.0157974701141486 ;~ 1 - 101.169368231525 ;~ 1 - 87.8702680159286 ;~ +>08:31:58 AutoIt3.exe ended.rc:0
comment:6 by , 11 years ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:7 by , 5 years ago
analysing carefully lead me to this conclusion
as the example does not reproduce the return behavior of StringReplace
but itis true that the StringRegReplace divide bt around 10
so StringReplace internally it is good that it call StringRegReplace
the gain of introducing and offset is very limited some percent with very big string
so I propose not to add it but just implement the inernal call in StringReplace
Local $sFileData, $iString, $iTimerDiff, $iExtended
Local $sTestINI = @DesktopDir& "\test.ini"
FileDelete($sTestINI)
Local $iFactor = 1
;~ Local $iOffset = 1/$iFactor
Local $iOffset = 2767600/$iFactor
If Not FileExists($sTestINI) Then
Local $hOut = FileOpen($sTestINI, 2)
For $i = 1 TO 1000000/$iFactor
FileWriteLine($hOut, " ")
Next
FileFlush($hOut)
FileSetPos($hOut, $iOffset + 1, 0)
FileWrite($hOut, "TestXXXX")
FileClose($hOut)
EndIf
$sFileData = FileRead(@DesktopDir& "\test.ini") ; test.ini = 10 Mb - includes inside, the string TestXXXX
$iTimerDiff = TimerInit()
$iString = StringReplace($sFileData, "TestXXXX", "TestYYYYY", 1)
$iExtended = @extended
$iTimerDiff = TimerDiff($iTimerDiff)
ConsoleWrite( "StringReplace " & $iExtended & " - " & $iTimerDiff & ' : $iString lenght = ' & Stringlen($iString) & ' Extended code: ' & $iExtended & @LF )
$iString=0
$iTimerDiff = TimerInit()
$iString = StringRegExpReplace($sFileData, "TestXXXX", "TestYYYYY", 1)
$iExtended = @extended
$iTimerDiff = TimerDiff($iTimerDiff)
ConsoleWrite( "StringRegExpReplace " & $iExtended & " - " & $iTimerDiff & ' : $iString lenght = ' & Stringlen($iString) & ' Extended code: ' & $iExtended & @LF & @LF)
$iString=0
$iTimerDiff = TimerInit()
$iString = StringInStr($sFileData, "TestXXXX", 1, 1, $iOffset)
$iTimerDiff = TimerDiff($iTimerDiff)
ConsoleWrite("StringInStr " & $iString & " - " & $iTimerDiff & @LF & @LF)
$iTimerDiff = TimerInit()
$iString = StringRegExp($sFileData, "TestXXXX", 1)
$iTimerDiff = TimerDiff($iTimerDiff)
ConsoleWrite("StringRegExp with offset " & 1 & " - " & $iTimerDiff & @LF)
$iTimerDiff = TimerInit()
$iString = StringRegExp($sFileData, "TestXXXX", 1, $iOffset)
$iTimerDiff = TimerDiff($iTimerDiff)
ConsoleWrite( "StringRegExp with offset " & $iOffset & " - " & $iTimerDiff & @LF)
;~ ================================= usual execution ===============================================
;~ StringReplace 1 - 216.104 : $iString lenght = 12000001 Extended code: 1
;~ StringRegExpReplace 1 - 31.271 : $iString lenght = 12000001 Extended code: 1
;~ StringInStr 2767602 - 0.0032
;~ StringRegExp with offset 1 - 11.9549
;~ StringRegExp with offset 2767600 - 8.2544
;~ ================================= some unusual execution ===============================================
;~ StringReplace 1 - 239.7323 : $iString lenght = 12000001 Extended code: 1
;~ StringRegExpReplace 1 - 30.3199 : $iString lenght = 12000001 Extended code: 1
;~ StringInStr 2767602 - 0.0045
;~ StringRegExp with offset 1 - 9.4972
;~ StringRegExp with offset 2767600 - 11.3512 >>>>>>>>>>>>>>>>> usely less than with offset = 1 <<<<<<<<<<<<<<<<<<<<<
comment:8 by , 5 years ago
in fact the main problem comes from the case sensitivity checking
so only this will be fixed
comment:10 by , 5 years ago
| Owner: | changed from to |
|---|
comment:11 by , 5 years ago
I reopen it as the proposed solution is not working when a special character is included in the replacement string \ . $ | [ ( { * + ? #
so I will just modified the StringReplace doc to point to StringRegExpReplace as the solution to use the same implementation will need to scan input string char by char as the present StringReplace implementation does.
It is better that the specific pattern of StringRegExpReplace be the user responsability.
comment:12 by , 5 years ago
| Milestone: | → 3.3.15.4 |
|---|---|
| Resolution: | → Completed |
| Status: | assigned → closed |
Added by revision [12451] in version: 3.3.15.4
comment:13 by , 5 years ago
| Resolution: | Completed |
|---|---|
| Status: | closed → reopened |
comment:14 by , 5 years ago
| Status: | reopened → assigned |
|---|
Finally I get a solution.
I sent the fix to Jon
comment:16 by , 2 years ago
| Owner: | changed from to |
|---|

Automatic ticket cleanup.