Morthawt Posted January 11, 2014 Share Posted January 11, 2014 #include <String.au3> $test = '<"100" tester="Things">Nowhere' $result = _StringBetween($test, '"', '"') For $a In $result ConsoleWrite($a & @CRLF) Next I would expect there to be a 2 entry array containing "100" and "Things". The issue is _StringBetween is not ignoring the end point and is instead using the end point character of " as the beginning of the next check in line. Expected result: 100 Things Actual result: 100 tester= Things Am I missing something or is this a bug? I would expect that once a "chunk" between something has been identified that it will then go from that point onwards and NOT muddy up the results by including a part of the previous check aka the " end character. Very confusing. Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
Morthawt Posted January 11, 2014 Author Share Posted January 11, 2014 In the _StringBetween function shouldn't there be a check so that if the beginning and the ending parts are identical that it will start searching for additional matches after the last ending part so as to not create unwanted results? Currently if the ending and starting points are the same, _StringBetween acts more like StringSplit, which is not what _Stringbetween is intended for. Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
jchd Posted January 11, 2014 Share Posted January 11, 2014 In most cases, using StringRegExp directly is a safer bet since you can tailor the pattern to match exactly the conditions your context imposes. 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 hereRegExp tutorial: enough to get startedPCRE 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 More sharing options...
Morthawt Posted January 11, 2014 Author Share Posted January 11, 2014 I am not very good with regex. But it appears after checking out the UDF for _StringBetween that it uses regex already, although none of it makes any sense to me at all. The function works great in every other case except when your beginning and ending are the same string. Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
Gianni Posted January 11, 2014 Share Posted January 11, 2014 I tested your script on AutoIt 3.3.8.1 and I get correct result: 100 Things Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Morthawt Posted January 11, 2014 Author Share Posted January 11, 2014 (edited) I tested your script on AutoIt 3.3.8.1 and I get correct result: 100 Things Hmm so something is gotten screwy with the new version of autoit? Can anyone else replicate this? It might need escalating to developers. Edited January 11, 2014 by Morthawt Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 11, 2014 Moderators Share Posted January 11, 2014 Morthawt,The RegEx used in the function has been changed to use a lookahead which means the second delimiter is not eaten as part of the pattern. A bug in my opinion as I would expect the behaviour as in 3.3.8.1 - please report it in Trac so that it can be discussed further. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jchd Posted January 11, 2014 Share Posted January 11, 2014 I raised the issue >some time ago see #2460 and svn revision 9009 by jpm. We regularly see examples with $end = $start where it is desirable to handle $end as the next $start, and another set of examples where it makes no sense. In all cases the reasonning behind a specific case is correct but gives incorrect results for the other semantic. Is this a situation where we want an extra $flag parameter? 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 hereRegExp tutorial: enough to get startedPCRE 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 More sharing options...
Moderators Melba23 Posted January 11, 2014 Moderators Share Posted January 11, 2014 jchd, Is this a situation where we want an extra $flag parameter?My first thought. Over to you! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Morthawt Posted January 11, 2014 Author Share Posted January 11, 2014 I really would hope this is resolved at some point because it renders the function useless in situations where the beginning and end are the same, if there is no other string you can use that would make it unique from the other you are completely "up"useless"the creek"completely"with no"truly"paddle"needs fixing"in sight". Splitting that up with the current _StringBetween just will not render a coherent sentence even though logically it should because all the bold words you want are between " and ", all the rest is between the instances we want in dead space. Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
jchd Posted January 11, 2014 Share Posted January 11, 2014 Morthawt, It is only useless in your precise situation. The change occured after several users complaining exactly for the other reason. There is no more logic or truth in any of the two versions. Hence I believe with Melba23 that an optional flag can make everyone happy. In the meantime, I can only recommend that you use StringRegExp as an interim solution. 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 hereRegExp tutorial: enough to get startedPCRE 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 More sharing options...
Moderators Melba23 Posted January 11, 2014 Moderators Share Posted January 11, 2014 Morthawt,Just add a renamed copy of the old version of the function to your script and call that instead: expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name...........: _StringBetween (3.3.8.1 version) ; Description ...: Returns the string between the start search string and the end search string. ; Syntax.........: _StringBetween($s_String, $s_start, $s_end[, $v_Case = -1]) ; Parameters ....: $s_String - The string to search. ; $s_start - The beginning of the string to find. Passing a blank string starts at the beginning ; $s_end - The end of the string to find. Passing a blank string searches from $s_start to end ; $v_Case - Optional: Case sensitive search. Default or -1 is not Case sensitive else Case sensitive. ; Return values .: Success - A 0 based $array[0] contains the first found string. ; Failure - 0 ; |@Error - 1 = No inbetween string found. ; Author ........: SmOke_N (Thanks to Valik for helping with the new StringRegExp (?s)(?i) isssue) ; Modified.......: SmOke_N - (Re-write for speed and accuracy) ; Remarks .......: 2009/05/03 Script breaking change, removed 5th parameter ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _StringBetween($s_String, $s_Start, $s_End, $v_Case = -1) ; Set case type Local $s_case = "" If $v_Case = Default Or $v_Case = -1 Then $s_case = "(?i)" ; Escape characters Local $s_pattern_escape = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)" $s_Start = StringRegExpReplace($s_Start, $s_pattern_escape, "\\$1") $s_End = StringRegExpReplace($s_End, $s_pattern_escape, "\\$1") ; If you want data from beginning then replace blank start with beginning of string If $s_Start = "" Then $s_Start = "\A" ; If you want data from a start to an end then replace blank with end of string If $s_End = "" Then $s_End = "\z" Local $a_ret = StringRegExp($s_String, "(?s)" & $s_case & $s_Start & "(.*?)" & $s_End, 3) If @error Then Return SetError(1, 0, 0) Return $a_ret EndFunc ;==>_StringBetweenNow, as you are making all the fuss about this - when are you going to create a bug in Trac? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Morthawt Posted January 11, 2014 Author Share Posted January 11, 2014 Thanks for that. I have made a ticket: http://www.autoitscript.com/trac/autoit/ticket/2618#ticket Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
guinness Posted January 11, 2014 Share Posted January 11, 2014 (edited) Morthawt, For...In should generally be used for Objects not Arrays as that's what For...To is designed for. I know people will argue with me on this, but I have explained my reasoning before, so just search the Forum. Edited January 11, 2014 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
DatMCEyeBall Posted January 11, 2014 Share Posted January 11, 2014 guinness, Then why does AutoIt allow the use of (1D) arrays with a For...In loop? "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation Link to comment Share on other sites More sharing options...
guinness Posted January 11, 2014 Share Posted January 11, 2014 (edited) guinness, Then why does AutoIt allow the use of (1D) arrays with a For...In loop? Using For...In with an Array is only useful if you're reading the contents of the Array. From past experience people tend not to read the help file thoroughly, so by getting into the habit of using For...To, will stop posts on the lines of "AutoIt is broken, can't write to Array entry" as they're using For...In. Tell me, did you know that Arrays couldn't be written to in a For...In loop until I told? Edited January 11, 2014 by guinness mLipok 1 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
DatMCEyeBall Posted January 11, 2014 Share Posted January 11, 2014 guinness, No, because I have a (good) habit of always using the For...To loop and not For...In (unless necessary). "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 11, 2014 Moderators Share Posted January 11, 2014 Hi,Please test this new version which has an additional parameter to determine the mode used:expandcollapse popup#include <Array.au3> $sTest = '<"100" tester="Things">Nowhere' $aRet = _StringBetween_New($sTest, '"', '"') ; Default mode 0 - ending delimiter is not part of next search _ArrayDisplay($aRet, "New - 8 style", Default, 8) $aRet = _StringBetween_New($sTest, '"', '"', Default, 1) ; Mode 1 - ending delimiter is part of next search _ArrayDisplay($aRet, "New - 10 Style", Default, 8) Func _StringBetween_New($sString, $sStart, $sEnd, $fCase = False, $iMode = 0) ; Set correct case sensitivity If $fCase = Default Then $fCase = False EndIf Local $sCase = "(?is)" If $fCase Then $sCase = "(?s)" EndIf ; Set mode If $iMode <> 1 Then $iMode = 0 ; If you want data from beginning then replace blank start with beginning of string $sStart = $sStart ? "\Q" & $sStart & "\E" : "\A" ; If you want data from a start to an end then replace blank with end of string If $iMode Then $sEnd = $sEnd ? "(?=\Q" & $sEnd & "\E)" : "\z" Else $sEnd = $sEnd ? "\Q" & $sEnd & "\E" : "\z" EndIf Local $aReturn = StringRegExp($sString, $sCase & $sStart & "(.*?)" & $sEnd, 3) If @error Then Return SetError(1, 0, 0) Return $aReturn EndFuncComments welcomed. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Morthawt Posted January 11, 2014 Author Share Posted January 11, 2014 Hi, Please test this new version which has an additional parameter to determine the mode used: expandcollapse popup#include <Array.au3> $sTest = '<"100" tester="Things">Nowhere' $aRet = _StringBetween_New($sTest, '"', '"') ; Default mode 0 - ending delimiter is not part of next search _ArrayDisplay($aRet, "New - 8 style", Default, 8) $aRet = _StringBetween_New($sTest, '"', '"', Default, 1) ; Mode 1 - ending delimiter is part of next search _ArrayDisplay($aRet, "New - 10 Style", Default, 8) Func _StringBetween_New($sString, $sStart, $sEnd, $fCase = False, $iMode = 0) ; Set correct case sensitivity If $fCase = Default Then $fCase = False EndIf Local $sCase = "(?is)" If $fCase Then $sCase = "(?s)" EndIf ; Set mode If $iMode <> 1 Then $iMode = 0 ; If you want data from beginning then replace blank start with beginning of string $sStart = $sStart ? "\Q" & $sStart & "\E" : "\A" ; If you want data from a start to an end then replace blank with end of string If $iMode Then $sEnd = $sEnd ? "(?=\Q" & $sEnd & "\E)" : "\z" Else $sEnd = $sEnd ? "\Q" & $sEnd & "\E" : "\z" EndIf Local $aReturn = StringRegExp($sString, $sCase & $sStart & "(.*?)" & $sEnd, 3) If @error Then Return SetError(1, 0, 0) Return $aReturn EndFunc Comments welcomed. M23 Works flawlessly for me I sense good things from this. Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
kylomas Posted January 11, 2014 Share Posted January 11, 2014 (edited) Hi M23, This is nit-picking and not a likely scenario but I thought I would mention it. Result strings containing an EOL will display as a concatenation in the array element. Might be confusing/misleading to some users. Not advocating any actrion one way or the other, just wanted to mention it... expandcollapse popup#include <Array.au3> ; mode 0 test $aRet = _StringBetween_New('\first' & @crlf & 'second\third\', '\', '\') if isarray($aRet) then ConsoleWrite('! _StringBetween Results mode = 0' & @LF) for $1 = 0 to ubound($aRet) - 1 ConsoleWrite($aRet[$1] & @LF) Next endif _ArrayDisplay($aRet, "Mode 0 - start and end ", Default, 8) ; mode 1 test $aRet = _StringBetween_New('\first' & @crlf & 'second\third\', '\', '\',default,1) if isarray($aRet) then ConsoleWrite('! _StringBetween Results mode = 1' & @LF) for $1 = 0 to ubound($aRet) - 1 ConsoleWrite($aRet[$1] & @LF) Next endif _ArrayDisplay($aRet, "Mode 1 - start and end ", Default, 8) Func _StringBetween_New($sString, $sStart, $sEnd, $fCase = False, $iMode = 0) ; Set correct case sensitivity If $fCase = Default Then $fCase = False EndIf Local $sCase = "(?is)" If $fCase Then $sCase = "(?s)" EndIf ; Set mode If $iMode <> 1 Then $iMode = 0 ; If you want data from beginning then replace blank start with beginning of string $sStart = $sStart ? "\Q" & $sStart & "\E" : "\A" ; If you want data from a start to an end then replace blank with end of string If $iMode Then $sEnd = $sEnd ? "(?=\Q" & $sEnd & "\E)" : "\z" Else $sEnd = $sEnd ? "\Q" & $sEnd & "\E" : "\z" EndIf Local $aReturn = StringRegExp($sString, $sCase & $sStart & "(.*?)" & $sEnd, 3) If @error Then Return SetError(1, 0, 0) Return $aReturn EndFunc Hmmm...Now where is that bird you are always trying to swat?!?? kylomas edit: Yes, I know it's how _ArrayDisplay works Edited January 11, 2014 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now