bogQ Posted May 12, 2009 Share Posted May 12, 2009 "710037HK32978BKKK310203EGNL904350FS18000AB" basicly i need 18000 so that i can add +1 on every loop so that i can send it when i rebuild the string from array (+1 on last numeric chars) SN:/ "710037HK32978BKKK310203EGNL904350FS18000AB" SN:/ "710037HK32978BKKK310203EGNL904350FS18001AB" SN:/ "710037HK32978BKKK310203EGNL904350FS18002AB" [0] 10 [1] 710037 [2] HK [3] 32978 [4] BKKK [5] 310203 [6] EGNL [7] 904350 [8] FS [9] 18000 [10] AB at the moment im trying it to check every position with stringmid combinated with srtinglen and try to determen on what position i need to split the string so that i can rebuild it later. Is there some other faster solution to do this (to split string on alpha and num chars)? TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 12, 2009 Share Posted May 12, 2009 "710037HK32978BKKK310203EGNL904350FS18000AB" basicly i need 18000 so that i can add +1 on every loop so that i can send it when i rebuild the string from array (+1 on last numeric chars) SN:/ "710037HK32978BKKK310203EGNL904350FS18000AB" SN:/ "710037HK32978BKKK310203EGNL904350FS18001AB" SN:/ "710037HK32978BKKK310203EGNL904350FS18002AB" [0] 10 [1] 710037 [2] HK [3] 32978 [4] BKKK [5] 310203 [6] EGNL [7] 904350 [8] FS [9] 18000 [10] AB at the moment im trying it to check every position with stringmid combinated with srtinglen and try to determen on what position i need to split the string so that i can rebuild it later. Is there some other faster solution to do this (to split string on alpha and num chars)? StringRegExp(), but you'll have to be specific about the expected format and what you want to get your pattern. What do you know about the string? Is the number always just before two alpha chars at the end of the string? Is the number variable length? Do you need all the other parts as separate elements, or just "before", "number", "after"? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
bogQ Posted May 12, 2009 Author Share Posted May 12, 2009 (edited) StringRegExp(), but you'll have to be specific about the expected format and what you want to get your pattern. What do you know about the string? Is the number always just before two alpha chars at the end of the string? Is the number variable length? Do you need all the other parts as separate elements, or just "before", "number", "after"? Is the number always just before two alpha chars at the end of the string? no, the serial number can b all in numeric or in the worst case numeric mixed with letters. In some cases it can b "ELD859501BT3615669" in some casses "8600115141210" Is the number variable length? its difrent from one serial on the product to another Do you need all the other parts as separate elements, or just "before", "number", "after"? basicly i need only last numeric part to go in +1, i tought that its easyer to split it to numeric and alpha and rebuild it, if there is a way to do... [0] 3 [1] 710037HK32978BKKK310203EGNL904350FS [2] 18000 ;<== +1 [3] AB" ... pls point me to that direction. edit: is there way to find last numeric chars in string so that i can replace them with +1 with stringreplace? Edited May 12, 2009 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
Yashied Posted May 12, 2009 Share Posted May 12, 2009 (edited) "710037HK32978BKKK310203EGNL904350FS18000AB" basicly i need 18000 so that i can add +1 on every loop so that i can send it when i rebuild the string from array (+1 on last numeric chars) SN:/ "710037HK32978BKKK310203EGNL904350FS18000AB" SN:/ "710037HK32978BKKK310203EGNL904350FS18001AB" SN:/ "710037HK32978BKKK310203EGNL904350FS18002AB" [0] 10 [1] 710037 [2] HK [3] 32978 [4] BKKK [5] 310203 [6] EGNL [7] 904350 [8] FS [9] 18000 [10] AB at the moment im trying it to check every position with stringmid combinated with srtinglen and try to determen on what position i need to split the string so that i can rebuild it later. Is there some other faster solution to do this (to split string on alpha and num chars)?Try this. expandcollapse popup#Include <Array.au3> const $SN = '710037HK32978BKKK310203EGNL904350FS18000AB' dim $Array = _StringSplit2BogQ($SN) _ArrayDisplay($Array) func _StringSplit2BogQ($sString) dim $Array[1] = [0] local $c, $b, $n, $r = false while $sString > '' $c = Stringleft($sString, 1) $sString = StringTrimLeft($sString, 1) $n = ($c >= '0') and ($c <= '9') if $Array[0] = 0 then $b = $n $r = 1 else if $b then if not $n then $b = not $b $r = 1 endif else if $n then $b = not $b $r = 1 endif endif endif if $r then redim $Array[$Array[0] + 2] $Array[0] += 1 $Array[$Array[0]] = $c $r = 0 else $Array[$Array[0]] &= $c endif wend return $Array endfunc; _StringSplit2BogQ Edited May 12, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Authenticity Posted May 12, 2009 Share Posted May 12, 2009 #include <Array.au3> Dim $sStr = '710037HK32978BKKK310203EGNL904350FS18000AB' Dim $aMatch = StringRegExp($sStr, '([A-Z]+|[0-9]+)', 3) If IsArray($aMatch) Then _ArrayInsert($aMatch, 0, UBound($aMatch)) _ArrayDisplay($aMatch) For $i = 1 To 10 $aMatch[$aMatch[0]-1] += 1 ConsoleWrite(_ArrayToString($aMatch, '') & @LF) Next EndIf Link to comment Share on other sites More sharing options...
Yashied Posted May 12, 2009 Share Posted May 12, 2009 (edited) #include <Array.au3> Dim $sStr = '710037HK32978BKKK310203EGNL904350FS18000AB' Dim $aMatch = StringRegExp($sStr, '([A-Z]+|[0-9]+)', 3) If IsArray($aMatch) Then _ArrayInsert($aMatch, 0, UBound($aMatch)) _ArrayDisplay($aMatch) For $i = 1 To 10 $aMatch[$aMatch[0]-1] += 1 ConsoleWrite(_ArrayToString($aMatch, '') & @LF) Next EndIfI think, ... I need better study StringRegExp() function. Edited May 12, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 12, 2009 Share Posted May 12, 2009 (edited) ...and the inverted greediness quantifier shall lead them: #include <Array.au3> Global $avInputs[5] = ["3710037HK32978BKKK310203EGNL904350FS18000AB", _ "ELD859501BT3615669", "8600115141210", "ABCDefghIJKLmnop", "710037HK32978BKKK310203EG.NL904350FS18#0_0-100AB"] Global $avOutputs[UBound($avInputs)], $avRegExp _ArrayDisplay($avInputs, "$avInputs") For $n = 0 To UBound($avInputs) - 1 $avRegExp = StringRegExp($avInputs[$n], "(?U)(.*)(\d+)(\D*)\z", 3) If @error Then $avOutputs[$n] = "Error (no digits): " & $avInputs[$n] Else $avRegExp[1] += 1 For $i = 0 to UBound($avRegExp) - 1 If StringStripWS($avInputs[$i], 8) <> "" Then $avOutputs[$n] &= $avRegExp[$i] Next EndIf Next _ArrayDisplay($avOutputs, "$avOuputs") Note handling is required for possibility that there are no digits in the string. Edit: Updated to include input example with non-alphanum chars. Edited May 12, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
bogQ Posted May 12, 2009 Author Share Posted May 12, 2009 (edited) ty all #include <Array.au3> Global $serial,$h $CountOfSerials = 10 Dim $sStr = '710037HK32978BKKK310203EG.NL904350FS18#0_0-100AB' Dim $aMatch = StringRegExp($sStr, '([A-Z]+|[#]+|[-]+|[_]+|[.]+|[0-9]+)', 3) If IsArray($aMatch) Then MsgBox(0,"",$sStr) ;~ Send($serial,1) ;~ Send("{ENTER}") _ArrayInsert($aMatch, 0, UBound($aMatch)) ;~ _ArrayDisplay($aMatch) Do For $f = $aMatch[0] To 1 Step -1 If Not StringIsAlpha($aMatch[$f]) Then $data = $aMatch[$f] _ArrayDelete($aMatch,$f) _ArrayInsert($aMatch,$f,$data+1 ) ExitLoop(1) EndIf Next For $y = 1 To $aMatch[0] $serial = $serial&$aMatch[$y] Next MsgBox(0,"",$serial) ;~ Send($serial,1) ;~ Send("{ENTER}") $serial = "" $h += 1 Until $h = $CountOfSerials-1 EndIf I think, ... I need better study StringRegExp() function. me too edit: Note handling is required for possibility that there are no digits in the string. serial number with no digits in it isnt serial ty all once more edit: editing so that i have thisone documented another way $serial = "abc123(*&^990j0a987079898da989o987%*&&)(%&$877654kh;l" $len = StringLen($serial) Global $number,$on,$first,$second For $x = $len To 1 Step -1 $l = StringMid($serial, $x, 1) If $l = "1" Or $l = "2" Or $l = "3" Or $l = "4" Or $l = "5" Or $l = "6" Or $l = "7" Or $l = "8" Or $l = "9" Or $l = "0" Then $number = $l&$number $on = "im on" Else If $on = "im on" Then $pos = $x ExitLoop(1) EndIf EndIf Next If $number = "" Then $number = $serial Else $first = StringLeft($serial,$pos) $second = StringMid($serial,$pos+StringLen($number)+1,$len-($pos+StringLen($number))) EndIf MsgBox(0,$number,$first&$number&$second) Edited July 7, 2009 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. 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