motormad Posted February 23, 2011 Share Posted February 23, 2011 I have to compare numbers of 2 dtabases. The input of the numbers is not correct done. So i have to split them before i can compare. Ill excplain the format of the numbers. There can be 7 to 8 digits before the '/' After the slash there are always 4 numbers. Now comes the trikky part. If there are 7 numbers on the left side the person who inputs somtimes uses tha 'space bar' and sometimes the right arrow. So the number can be 1234567/0100 or 1234567_/0100 I think i have to use 'StringRegExpReplace' sombody cares to help me ? :-) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 23, 2011 Moderators Share Posted February 23, 2011 motormad, I would try this: Global $aData[3] = ["1234567/0100", _ "12345678/0100", _ "1234567 /0100"] For $i = 0 To 2 ConsoleWrite(StringRegExpReplace($aData[$i], "(?U)(\d*)(?:\s?)/(\d{4})", "$1/$2") & @CRLF) Next Explanation: (?U) = not greedy (\d*) = a number of digits (as small as possible because of the above) (?:\s?) = a possible space (in a non-capturing group) / = literal / (\d{4}) = 4 digits All clear? 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...
motormad Posted February 23, 2011 Author Share Posted February 23, 2011 (edited) Realy mate... i do not understan a thing about it. But it almost works for me. 1234567/0010 => 1234567/0010 1234567_/0100 => 1234567_/0100 1234567 /0100 => 1234567/0100 So i only neef the 1234567_/0100 to become 1234567/0100 Ill try to get it tomorrow. thanx for your help (so fast ) Edited February 23, 2011 by motormad Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 23, 2011 Moderators Share Posted February 23, 2011 motormad,My apologies, I thought the underscore was to only there to show that there was a space. All that is needed to fix that is this slightly changed version:ConsoleWrite(StringRegExpReplace($aData[$i], "(?U)(\d*)(?:[\s|_]?)/(\d{4})", "$1/$2") & @CRLF)The only change is in here (?:[\s|_]?) where we look for either a space or underscore, neither of which might be present.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...
motormad Posted February 24, 2011 Author Share Posted February 24, 2011 (edited) Thanx Melba23 :-) I got a new Question I like to search in an array. I got your code to get the correct format I put the string in variable $a But in the array are also wrong formats. If there are correct formats in the array then this code would work. func ExsIsts($WOenTAAK) ConsoleWrite('_ArraySearch : ' & $WOenTAAK & @CRLF) local $iIndex local $sColumn $sColumn = 4 $iIndex = _ArraySearch($AR_ACCES1, $a, 0, 0, 0, 1, 1, $sColumn) return $iIndex If @error Then Exit return 0 endfunc but if $a = 1234567/0100 and in column 4 is string 1234567_/0100 then the return would be 0 because 1234567/0100 <> 1234567_/0100 Edited February 24, 2011 by motormad Link to comment Share on other sites More sharing options...
GEOSoft Posted February 24, 2011 Share Posted February 24, 2011 $iVal = StringRegExpReplace($iVal, "[\h_]*", "") @M23 When using a group "[******]" you don't need the pipe (OR). It is assumed and actually the pipe could throw it off. Incorrect = [\d|_]* Correct = [\d_]* ; Matches 0 or more of either \d or _ George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 24, 2011 Moderators Share Posted February 24, 2011 George, Thanks. 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...
GEOSoft Posted February 24, 2011 Share Posted February 24, 2011 NP, I'm just glad to see you still trying. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
motormad Posted February 24, 2011 Author Share Posted February 24, 2011 Damn people your fast. I think of going to solve my problem like this func ExsIsts22($WOenTAAK) local $rows local $i $rows = UBound($aWO_Nr) $i = 1 Do if $WOenTAAK=StringRegExpReplace($aWO_Nr[$i], "(?U)(\d*)(?:[\s|_]?)/(\d{4})", "$1/$2")Then msgbox " its a match" endif $i = $i + 1 Until $i = $rows endfunc Link to comment Share on other sites More sharing options...
GEOSoft Posted February 24, 2011 Share Posted February 24, 2011 That will do it but primarily all you are going to replace is a horizontal space or an underscore with a blank string so you don't have to worry about any other characters at all. Just replace the ones you don't want (\h and _) and that's what the expression I gave you will do. Pretty simple and straight forward. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
motormad Posted February 28, 2011 Author Share Posted February 28, 2011 GEOSoft I'm getting it but... What if my problem is this : 10 has to be 0010 5 has to be 0001 800 => 0800 etc ... Mabe its not the StringRegExpReplace i have to use for this problem ? Link to comment Share on other sites More sharing options...
motormad Posted February 28, 2011 Author Share Posted February 28, 2011 (edited) $i_input_len = StringLen($aArray[$A][2]) If $i_input_len=1 Then $aArray[$A][2]=$aArray[$A][1] & "/000" & $aArray[$A][2] elseIf $i_input_len=2 Then $aArray[$A][2]=$aArray[$A][1] & "/00" & $aArray[$A][2] elseIf $i_input_len=3 Then $aArray[$A][2]=$aArray[$A][1] & "/0" & $aArray[$A][2] Else $aArray[$A][2] = $aArray[$A][1] & "/" & $aArray[$A][2] endif $aReturn[$A-1] = $aArray[$A][2] I think it can be done shorter But this works for me :-) 12345678 and 10 => 12345678/0010 but 12345678 & "/" & 10 is 12345678/10 Edited February 28, 2011 by motormad Link to comment Share on other sites More sharing options...
GEOSoft Posted February 28, 2011 Share Posted February 28, 2011 GEOSoftI'm getting it but...What if my problem is this :10 has to be 00105 has to be 0001800 => 0800etc ...Mabe its not the StringRegExpReplace i have to use for this problem ?See StringFormat() in the help file. You may also want to use a RegExp before or after using the StringRegExpReplace() George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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